finally works, although not correctly
This commit is contained in:
BIN
doc/2016-10-13_1.png
Normal file
BIN
doc/2016-10-13_1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
BIN
doc/2016-10-13_2.png
Normal file
BIN
doc/2016-10-13_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
doc/2016-10-13_works.png
Normal file
BIN
doc/2016-10-13_works.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.3 KiB |
BIN
doc/2016-10-13_works_not.png
Normal file
BIN
doc/2016-10-13_works_not.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
@ -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();
|
||||
|
Reference in New Issue
Block a user