From 9cdbf0a8e7a84d9edf516f5e2db462e1a5a265e9 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Fri, 14 Oct 2016 14:57:26 +0200 Subject: [PATCH] introduce direction flag --- src/inverterCtrl.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) 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++;