From 9316ef363fd6e262d60f2f4102180ccf0049f94a Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Sat, 15 Oct 2016 11:27:32 +0200 Subject: [PATCH] strange thing when write pulseWidths array --- src/inverter.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/inverter.c b/src/inverter.c index ec7a964..8caa598 100644 --- a/src/inverter.c +++ b/src/inverter.c @@ -14,6 +14,33 @@ #include "inverter.h" +#if 1 +#define NUM_OF_SINE_VALUES 21 + +float sineValues[NUM_OF_SINE_VALUES] = { + 0.1490, + 0.2948, + 0.4339, + 0.5633, + 0.6802, + 0.7818, + 0.8660, + 0.9309, + 0.9749, + 0.9972, + 0.9972, + 0.9749, + 0.9309, + 0.8660, + 0.7818, + 0.6802, + 0.5633, + 0.4339, + 0.2948, + 0.1490, + 0.0000 +}; +#else #define NUM_OF_SINE_VALUES 20 float sineValues[NUM_OF_SINE_VALUES] = { @@ -38,6 +65,7 @@ float sineValues[NUM_OF_SINE_VALUES] = { 0.1564, 0.0000 }; +#endif volatile uint16_t pulseWidths[NUM_OF_SINE_VALUES * 2]; volatile uint8_t pulseWidthIdx = 0; @@ -50,7 +78,7 @@ ISR(TIMER0_A0, TA0_ISR_Ovrfl) { } uint16_t pw = pulseWidths[pulseWidthIdx + activeOffset]; - if (pw != 0) { + if (pulseWidthIdx != (NUM_OF_SINE_VALUES - 1)) { TA0CCR1 = pw; P2OUT |= BIT1; }