diff --git a/doc/2016-10-13_1.png b/doc/2016-10-13_1.png new file mode 100644 index 0000000..25aa2de Binary files /dev/null and b/doc/2016-10-13_1.png differ diff --git a/doc/2016-10-13_2.png b/doc/2016-10-13_2.png new file mode 100644 index 0000000..5ec7b1a Binary files /dev/null and b/doc/2016-10-13_2.png differ diff --git a/doc/2016-10-13_works.png b/doc/2016-10-13_works.png new file mode 100644 index 0000000..e9a297a Binary files /dev/null and b/doc/2016-10-13_works.png differ diff --git a/doc/2016-10-13_works_not.png b/doc/2016-10-13_works_not.png new file mode 100644 index 0000000..8e1a7bf Binary files /dev/null and b/doc/2016-10-13_works_not.png differ diff --git a/src/inverterCtrl.c b/src/inverterCtrl.c index c9a43be..b1e52f3 100644 --- a/src/inverterCtrl.c +++ b/src/inverterCtrl.c @@ -25,25 +25,19 @@ ISR(TIMER1_A0, TA1_ISR_Ovrfl) { if (pulseWidthIdx == 0) { P2OUT |= BIT3; } + if (pulseWidthIdx == 13) { + P2OUT |= BIT4; + } + if (pulseWidthIdx == 26) { + P2OUT |= BIT5; + } pulseWidthIdx++; - if (pulseWidthIdx >= NUM_OF_SINE_VALUES) { + if (pulseWidthIdx >= NUM_OF_SINE_VALUES * 2) { pulseWidthIdx = 0; } } -ISR(TIMER1_A1, TA1_ISR_Comp) { - __disable_interrupt(); - uint16_t taiv = TA1IV; - if (P2OUT & BIT3) { - if (taiv == TA1IV_TACCR1) { - P2OUT |= BIT4; - } else if (taiv == TA1IV_TACCR2) { - P2OUT |= BIT5; - } - } - __enable_interrupt(); -} @@ -66,11 +60,7 @@ void inverterCtrlInit() { TA1CTL = MC_1 | ID_0 | TASSEL_2 | TACLR; TA1CCTL0 = CCIE | OUTMOD_4; - TA1CCTL1 = CCIE; - TA1CCTL2 = CCIE; TA1CCR0 = 0; - TA1CCR1 = 0; - TA1CCR2 = 0; } @@ -78,18 +68,11 @@ void inverterCtrlSetFrequency(uint16_t f) { float ff = (float)f; float slotLength = 2 / (ff * 400e-9 * NUM_OF_SINE_VALUES); uint16_t sl = (uint16_t)slotLength; - float phase2start = slotLength / 3; - uint16_t p2s = (uint16_t)phase2start; - float phase3start = slotLength / 3 * 2; - uint16_t p3s = (uint16_t)phase3start; - __disable_interrupt(); TA1CTL = MC_0; P2OUT &= ~(BIT3 | BIT4 | BIT5); TA1CCR0 = sl; - TA1CCR1 = p2s; - TA1CCR2 = p3s; pulseWidthIdx = 0; TA1CTL = MC_1 | ID_0 | TASSEL_2 | TACLR; __enable_interrupt();