working a bit better
This commit is contained in:
parent
4dea7fe895
commit
a2020fb38c
BIN
doc/inverter0_2016-09-22_1.png
Normal file
BIN
doc/inverter0_2016-09-22_1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.5 KiB |
BIN
doc/inverter0_2016-09-22_2.png
Normal file
BIN
doc/inverter0_2016-09-22_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
@ -28,37 +28,34 @@ float sineValues[NUM_OF_SINE_VALUES] = {
|
|||||||
0.0000,
|
0.0000,
|
||||||
};
|
};
|
||||||
|
|
||||||
volatile uint16_t pulseWidths[NUM_OF_SINE_VALUES * 2] = { 0,50,0,50,0,50,0,50,0,50,0,0,0,0,0,0,0,0,0,0 };
|
volatile uint16_t pulseWidths[NUM_OF_SINE_VALUES * 2] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
|
||||||
|
volatile uint8_t pulseWidthIdx = 0;
|
||||||
volatile uint8_t activeOffset = 0;
|
volatile uint8_t activeOffset = 0;
|
||||||
|
|
||||||
|
|
||||||
volatile uint16_t uiSlotLength = 2040;
|
|
||||||
|
|
||||||
ISR(TIMER1_A0, TA1_ISR_Ovrfl) {
|
ISR(TIMER1_A0, TA1_ISR_Ovrfl) {
|
||||||
static uint16_t myUiSlotLength = 0;
|
if (pulseWidthIdx == 0) {
|
||||||
if (myUiSlotLength != uiSlotLength) {
|
|
||||||
TA1CCR0 = uiSlotLength;
|
|
||||||
myUiSlotLength = uiSlotLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t idx = 0;
|
|
||||||
|
|
||||||
if (idx == 0) {
|
|
||||||
P1OUT ^= BIT1;
|
P1OUT ^= BIT1;
|
||||||
}
|
}
|
||||||
|
|
||||||
TA1CCR1 = pulseWidths[idx + activeOffset];
|
uint16_t pw = pulseWidths[pulseWidthIdx + activeOffset];
|
||||||
|
if (pw != 0) {
|
||||||
|
TA1CCR1 = pw;
|
||||||
|
P2OUT |= BIT1;
|
||||||
|
}
|
||||||
|
|
||||||
idx++;
|
pulseWidthIdx++;
|
||||||
if (idx >= NUM_OF_SINE_VALUES) {
|
if (pulseWidthIdx >= NUM_OF_SINE_VALUES) {
|
||||||
idx = 0;
|
pulseWidthIdx = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//ISR(TIMER1_A1, TA1_ISR_Comp) {
|
ISR(TIMER1_A1, TA1_ISR_Comp) {
|
||||||
//
|
if (TA1IV & TA1IV_TACCR1) {
|
||||||
//}
|
P2OUT &= ~BIT1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -68,19 +65,15 @@ void inverterInit() {
|
|||||||
|
|
||||||
P2OUT &= ~BIT1;
|
P2OUT &= ~BIT1;
|
||||||
P2DIR |= BIT1;
|
P2DIR |= BIT1;
|
||||||
P2SEL |= BIT1;
|
|
||||||
|
|
||||||
P2OUT &= ~BIT0;
|
P2OUT &= ~BIT0;
|
||||||
P2DIR |= BIT0;
|
P2DIR |= BIT0;
|
||||||
P2SEL |= BIT0;
|
P2SEL |= BIT0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TA1CTL = MC_1 | ID_1 | TASSEL_2 | TACLR;
|
TA1CTL = MC_1 | ID_1 | TASSEL_2 | TACLR;
|
||||||
TA1CCTL0 = CCIE | OUTMOD_4;
|
TA1CCTL0 = CCIE | OUTMOD_4;
|
||||||
TA1CCTL1 = OUTMOD_7;
|
TA1CCTL1 = CCIE;
|
||||||
TA1CCR0 = 5000;
|
TA1CCR0 = 0;
|
||||||
TA1CCR1 = 0;
|
TA1CCR1 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,6 +88,7 @@ void inverterSetFrequency(uint16_t f) {
|
|||||||
|
|
||||||
__disable_interrupt();
|
__disable_interrupt();
|
||||||
activeOffset = currentOffset;
|
activeOffset = currentOffset;
|
||||||
uiSlotLength = (uint16_t)slotLength;
|
TA1CCR0 = (uint16_t)slotLength;
|
||||||
|
pulseWidthIdx = 0;
|
||||||
__enable_interrupt();
|
__enable_interrupt();
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ int main() {
|
|||||||
|
|
||||||
__enable_interrupt();
|
__enable_interrupt();
|
||||||
|
|
||||||
//inverterSetFrequency(100);
|
inverterSetFrequency(100);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user