/* www.MicroDigitalEd.com * p11_5.c Deadband creation using Center-aligned PWM * * The Timer_A0 is configured for center-aligned PWM. * channel 3 is configured for 40% duty cycle pulse high. * channel 4 is configured for 60% duty cycle pulse low. * This creates a 10% deadband between channel 3 high and * channel 4 high. * * Tested with Keil 5.20 and MSP432 Device Family Pack V2.2.0 * on XMS432P401R Rev C. */ #include "msp.h" void delayMs(int n); int main(void) { /* Configure P2.7 and P2.6 as Timer A0.4 output */ P2->SEL0 |= 0xC0; P2->SEL1 &= ~0xC0; P2->DIR |= 0xC0; /* configure TimerA0.3 and TimerA0.4 as PWM */ TIMER_A0->CCR[0] = 50000-1; /* PWM Period */ TIMER_A0->CCR[3] = 50000*40/100; /* CCR3 PWM duty cycle 40% */ TIMER_A0->CCTL[3] = 0x40; /* CCR3 toggle/reset mode */ TIMER_A0->CCR[4] = 50000*60/100; /* CCR4 PWM duty cycle 60% inverted */ TIMER_A0->CCTL[4] = 0xC0; /* CCR4 toggle/set mode */ TIMER_A0->CTL = 0x0234; /* use SMCLK, up/down mode, clear TA0R register */ while (1) { } }