diff --git a/src/inverterCtrl.c b/src/inverterCtrl.c index b1e52f3..8327d42 100644 --- a/src/inverterCtrl.c +++ b/src/inverterCtrl.c @@ -19,17 +19,30 @@ volatile uint8_t pulseWidthIdx = 0; +volatile bool direction = true; ISR(TIMER1_A0, TA1_ISR_Ovrfl) { - if (pulseWidthIdx == 0) { - P2OUT |= BIT3; - } - if (pulseWidthIdx == 13) { - P2OUT |= BIT4; - } - if (pulseWidthIdx == 26) { - P2OUT |= BIT5; + if (direction) { + if (pulseWidthIdx == 0) { + P2OUT |= BIT3; + } + if (pulseWidthIdx == 13) { + P2OUT |= BIT4; + } + if (pulseWidthIdx == 26) { + P2OUT |= BIT5; + } + } else { + if (pulseWidthIdx == 0) { + P2OUT |= BIT4; + } + if (pulseWidthIdx == 13) { + P2OUT |= BIT3; + } + if (pulseWidthIdx == 26) { + P2OUT |= BIT5; + } } pulseWidthIdx++;