use loop for PWM output
This commit is contained in:
parent
85264166c8
commit
02b6e08279
34
dmx8chan.c
34
dmx8chan.c
|
@ -51,44 +51,28 @@ ISR(SIG_OVERFLOW1)
|
||||||
/*
|
/*
|
||||||
* Timer 1 Compare Match (every 40us)
|
* Timer 1 Compare Match (every 40us)
|
||||||
* - schedule next compare match in 40us
|
* - schedule next compare match in 40us
|
||||||
|
* - set PWM Outputs (PORTB)
|
||||||
*/
|
*/
|
||||||
ISR(SIG_OUTPUT_COMPARE1A)
|
ISR(SIG_OUTPUT_COMPARE1A)
|
||||||
{
|
{
|
||||||
OCR1A = pwm_load;
|
OCR1A = pwm_load;
|
||||||
pwm_load += TIMER1_STEP;
|
pwm_load += TIMER1_STEP;
|
||||||
|
|
||||||
uint8_t *tmp = chan;
|
|
||||||
uint8_t out = PORTB;
|
|
||||||
|
|
||||||
cnt--;
|
cnt--;
|
||||||
|
|
||||||
|
uint8_t out = PORTB;
|
||||||
if (cnt == 0xFF)
|
if (cnt == 0xFF)
|
||||||
out = 0x00;
|
out = 0x00;
|
||||||
|
|
||||||
if (*tmp++ >= cnt)
|
uint8_t i, shift = 1;
|
||||||
out |= (1<<PORTB0);
|
uint8_t *tmp = chan;
|
||||||
|
|
||||||
if (*tmp++ >= cnt)
|
for (i = 0; i < 8; i++) {
|
||||||
out |= (1<<PORTB1);
|
if (*tmp++ >= cnt)
|
||||||
|
out |= shift;
|
||||||
if (*tmp++ >= cnt)
|
|
||||||
out |= (1<<PORTB2);
|
|
||||||
|
|
||||||
if (*tmp++ >= cnt)
|
|
||||||
out |= (1<<PORTB3);
|
|
||||||
|
|
||||||
if (*tmp++ >= cnt)
|
|
||||||
out |= (1<<PORTB4);
|
|
||||||
|
|
||||||
if (*tmp++ >= cnt)
|
|
||||||
out |= (1<<PORTB5);
|
|
||||||
|
|
||||||
if (*tmp++ >= cnt)
|
|
||||||
out |= (1<<PORTB6);
|
|
||||||
|
|
||||||
if (*tmp++ >= cnt)
|
|
||||||
out |= (1<<PORTB7);
|
|
||||||
|
|
||||||
|
shift <<= 1;
|
||||||
|
}
|
||||||
PORTB = out;
|
PORTB = out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue