tested version

This commit is contained in:
Olaf Rempel 2006-05-27 16:46:09 +02:00
parent 4d6f3bfec9
commit 85264166c8
2 changed files with 21 additions and 17 deletions

View File

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

View File

@ -22,15 +22,15 @@
#include <avr/interrupt.h> #include <avr/interrupt.h>
#define TIMER1_STEP 40 #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 // rx variables
static uint16_t rx_chan; static uint16_t rx_chan;
static uint16_t my_base; static uint16_t my_base;
// channel values
static uint8_t chan[8] = { 0xFF, 0xC0, 0xB0, 0x80, 0x40, 0x20, 0x10, 0x00 };
// next OCR1 value // next OCR1 value
static uint8_t cnt; static uint8_t cnt;
static uint16_t pwm_load; static uint16_t pwm_load;
@ -43,7 +43,7 @@ static uint16_t pwm_load;
ISR(SIG_OVERFLOW1) ISR(SIG_OVERFLOW1)
{ {
TCNT1 = TIMER1_RELOAD; TCNT1 = TIMER1_RELOAD;
OCR1 = (TIMER1_RELOAD + TIMER1_STEP); OCR1A = (TIMER1_RELOAD + TIMER1_STEP);
pwm_load = (TIMER1_RELOAD + (TIMER1_STEP * 2)); pwm_load = (TIMER1_RELOAD + (TIMER1_STEP * 2));
cnt = 0x00; cnt = 0x00;
} }
@ -54,39 +54,42 @@ ISR(SIG_OVERFLOW1)
*/ */
ISR(SIG_OUTPUT_COMPARE1A) ISR(SIG_OUTPUT_COMPARE1A)
{ {
OCR1 = pwm_load; OCR1A = pwm_load;
pwm_load += TIMER1_STEP; pwm_load += TIMER1_STEP;
uint8_t *tmp = chan; uint8_t *tmp = chan;
uint8_t out = PORTB;
cnt--; cnt--;
if (cnt == 0xFF) if (cnt == 0xFF)
PORTB = 0x00; out = 0x00;
if (*tmp++ >= cnt) if (*tmp++ >= cnt)
PORTB |= (1<<PORTB0); out |= (1<<PORTB0);
if (*tmp++ >= cnt) if (*tmp++ >= cnt)
PORTB |= (1<<PORTB1); out |= (1<<PORTB1);
if (*tmp++ >= cnt) if (*tmp++ >= cnt)
PORTB |= (1<<PORTB2); out |= (1<<PORTB2);
if (*tmp++ >= cnt) if (*tmp++ >= cnt)
PORTB |= (1<<PORTB3); out |= (1<<PORTB3);
if (*tmp++ >= cnt) if (*tmp++ >= cnt)
PORTB |= (1<<PORTB4); out |= (1<<PORTB4);
if (*tmp++ >= cnt) if (*tmp++ >= cnt)
PORTB |= (1<<PORTB5); out |= (1<<PORTB5);
if (*tmp++ >= cnt) if (*tmp++ >= cnt)
PORTB |= (1<<PORTB6); out |= (1<<PORTB6);
if (*tmp++ >= cnt) if (*tmp++ >= cnt)
PORTB |= (1<<PORTB7); out |= (1<<PORTB7);
PORTB = out;
} }
/* /*
@ -106,6 +109,7 @@ ISR(SIG_UART_RECV)
} else { } else {
uint8_t tmp = UDR; uint8_t tmp = UDR;
tmp = tmp;
} }
} }