Browse Source

tested version

master
Olaf Rempel 13 years ago
parent
commit
85264166c8
2 changed files with 21 additions and 17 deletions
  1. +2
    -2
      Makefile
  2. +19
    -15
      dmx8chan.c

+ 2
- 2
Makefile View File

@@ -1,5 +1,5 @@
PRG = dmx3chan
OBJ = dmx3chan.o
PRG = dmx8chan
OBJ = dmx8chan.o
MCU_TARGET = at90s2313
OPTIMIZE = -Os


+ 19
- 15
dmx8chan.c View File

@@ -22,15 +22,15 @@
#include <avr/interrupt.h>

#define TIMER1_STEP 40
#define TIMER1_RELOAD (0xFFFF - (256 * TIMER1_STEP))
#define TIMER1_RELOAD (0xFFFF - (255 * TIMER1_STEP))

// channel values
volatile uint8_t chan[8] = { 0xFF, 0xFE, 0x80, 0x40, 0x20, 0x10, 0x01, 0x00 };

// rx variables
static uint16_t rx_chan;
static uint16_t my_base;

// channel values
static uint8_t chan[8] = { 0xFF, 0xC0, 0xB0, 0x80, 0x40, 0x20, 0x10, 0x00 };

// next OCR1 value
static uint8_t cnt;
static uint16_t pwm_load;
@@ -43,7 +43,7 @@ static uint16_t pwm_load;
ISR(SIG_OVERFLOW1)
{
TCNT1 = TIMER1_RELOAD;
OCR1 = (TIMER1_RELOAD + TIMER1_STEP);
OCR1A = (TIMER1_RELOAD + TIMER1_STEP);
pwm_load = (TIMER1_RELOAD + (TIMER1_STEP * 2));
cnt = 0x00;
}
@@ -54,39 +54,42 @@ ISR(SIG_OVERFLOW1)
*/
ISR(SIG_OUTPUT_COMPARE1A)
{
OCR1 = pwm_load;
OCR1A = pwm_load;
pwm_load += TIMER1_STEP;

uint8_t *tmp = chan;
uint8_t out = PORTB;

cnt--;

if (cnt == 0xFF)
PORTB = 0x00;
out = 0x00;

if (*tmp++ >= cnt)
PORTB |= (1<<PORTB0);
out |= (1<<PORTB0);

if (*tmp++ >= cnt)
PORTB |= (1<<PORTB1);
out |= (1<<PORTB1);

if (*tmp++ >= cnt)
PORTB |= (1<<PORTB2);
out |= (1<<PORTB2);

if (*tmp++ >= cnt)
PORTB |= (1<<PORTB3);
out |= (1<<PORTB3);

if (*tmp++ >= cnt)
PORTB |= (1<<PORTB4);
out |= (1<<PORTB4);

if (*tmp++ >= cnt)
PORTB |= (1<<PORTB5);
out |= (1<<PORTB5);

if (*tmp++ >= cnt)
PORTB |= (1<<PORTB6);
out |= (1<<PORTB6);

if (*tmp++ >= cnt)
PORTB |= (1<<PORTB7);
out |= (1<<PORTB7);

PORTB = out;
}

/*
@@ -106,6 +109,7 @@ ISR(SIG_UART_RECV)

} else {
uint8_t tmp = UDR;
tmp = tmp;
}
}


Loading…
Cancel
Save