introduce direction flag

This commit is contained in:
Wolfgang Hottgenroth
2016-10-14 14:57:26 +02:00
parent daf4613cd1
commit 9cdbf0a8e7

View File

@ -19,9 +19,11 @@
volatile uint8_t pulseWidthIdx = 0;
volatile bool direction = true;
ISR(TIMER1_A0, TA1_ISR_Ovrfl) {
if (direction) {
if (pulseWidthIdx == 0) {
P2OUT |= BIT3;
}
@ -31,6 +33,17 @@ ISR(TIMER1_A0, TA1_ISR_Ovrfl) {
if (pulseWidthIdx == 26) {
P2OUT |= BIT5;
}
} else {
if (pulseWidthIdx == 0) {
P2OUT |= BIT4;
}
if (pulseWidthIdx == 13) {
P2OUT |= BIT3;
}
if (pulseWidthIdx == 26) {
P2OUT |= BIT5;
}
}
pulseWidthIdx++;
if (pulseWidthIdx >= NUM_OF_SINE_VALUES * 2) {