From 85264166c823af18053c4616ff3ff63d9cabb8ed Mon Sep 17 00:00:00 2001 From: Olaf Rempel Date: Sat, 27 May 2006 16:46:09 +0200 Subject: [PATCH] tested version --- Makefile | 4 ++-- dmx8chan.c | 34 +++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 52f0906..75c0d01 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -PRG = dmx3chan -OBJ = dmx3chan.o +PRG = dmx8chan +OBJ = dmx8chan.o MCU_TARGET = at90s2313 OPTIMIZE = -Os diff --git a/dmx8chan.c b/dmx8chan.c index 3758a10..26bc894 100644 --- a/dmx8chan.c +++ b/dmx8chan.c @@ -22,15 +22,15 @@ #include #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<= cnt) - PORTB |= (1<= cnt) - PORTB |= (1<= cnt) - PORTB |= (1<= cnt) - PORTB |= (1<= cnt) - PORTB |= (1<= cnt) - PORTB |= (1<= cnt) - PORTB |= (1<