introduce direction flag
This commit is contained in:
@ -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) {
|
||||
|
Reference in New Issue
Block a user