symmetric wave
This commit is contained in:
parent
d1841f8af5
commit
86f7ef98f3
@ -46,7 +46,6 @@ volatile uint8_t activeOffset = 0;
|
||||
|
||||
ISR(TIMER1_A0, TA1_ISR_Ovrfl) {
|
||||
if (pulseWidthIdx == 0) {
|
||||
P1OUT ^= (BIT1 | BIT0);
|
||||
}
|
||||
|
||||
uint16_t pw = pulseWidths[pulseWidthIdx + activeOffset];
|
||||
@ -63,8 +62,11 @@ ISR(TIMER1_A0, TA1_ISR_Ovrfl) {
|
||||
|
||||
ISR(TIMER1_A1, TA1_ISR_Comp) {
|
||||
__disable_interrupt();
|
||||
if (TA1IV & TA1IV_TACCR1) {
|
||||
uint16_t taiv = TA1IV;
|
||||
if (taiv & TA1IV_TACCR1) {
|
||||
P2OUT &= ~BIT1;
|
||||
} else if ((taiv && TA1IV_TACCR2) && (pulseWidthIdx == 0)) {
|
||||
P1OUT ^= (BIT1 | BIT0);
|
||||
}
|
||||
__enable_interrupt();
|
||||
}
|
||||
@ -86,8 +88,10 @@ void inverterInit() {
|
||||
TA1CTL = MC_1 | ID_0 | TASSEL_2 | TACLR;
|
||||
TA1CCTL0 = CCIE | OUTMOD_4;
|
||||
TA1CCTL1 = CCIE;
|
||||
TA1CCTL2 = CCIE;
|
||||
TA1CCR0 = 0;
|
||||
TA1CCR1 = 0;
|
||||
TA1CCR2 = 1;
|
||||
}
|
||||
|
||||
void inverterSetFrequency(uint16_t f) {
|
||||
@ -97,8 +101,8 @@ void inverterSetFrequency(uint16_t f) {
|
||||
|
||||
uint8_t currentOffset = (activeOffset == 0) ? NUM_OF_SINE_VALUES : 0;
|
||||
for (uint8_t i = 0; i < NUM_OF_SINE_VALUES; i++) {
|
||||
uint16_t pw = (uint16_t)(slotLength * sineValues[i]);
|
||||
pulseWidths[i + currentOffset] = (pw == sl) ? (pw - 25) : pw;
|
||||
uint16_t pw = (uint16_t)(slotLength * 0.9 * sineValues[i]);
|
||||
pulseWidths[i + currentOffset] = pw;
|
||||
}
|
||||
|
||||
__disable_interrupt();
|
||||
|
@ -30,7 +30,7 @@ int main() {
|
||||
|
||||
__enable_interrupt();
|
||||
|
||||
inverterSetFrequency(75);
|
||||
inverterSetFrequency(50);
|
||||
|
||||
while (1) {
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user