I'm using MSP430F5342.
My HW schematic requires PWM signals on
pin 18 P1.5/TA0.4 <- no problem, duty cycle on TA0CCR4, period on TA0CCR0
pin 20 P1.7/TA1.0 <- problem, duty cycle on TA1CCR0, period on TA1CCR0
All sample code I've seen uses TAxCCRn for duty cycle on peripheral TAx.n and TAxCCR0 for period. For TA1.0, n=0 and both period and duty cycle need to be in TA1CCR0. I do get a PWM, but with period = duty cycle. (Actually, the period is internally one clock longer.) So TA1CCR0=1 gives HIGH one clock in a two-clock period, or 50% duty at 4MHz (8MHz/2). TA1CCR0=2 gives HIGH two clocks in a three-clock period, or 67% duty at 2.667MHz (8MHz/3). You get the idea.
The actual code uses a driver library function, but single stepping through it confirms that TA1CCR0 is being overwritten.
Timer_generatePWM(
__MSP430_BASEADDRESS_T1A3__, // P1.7/TA1.0 uses timer A1
TIMER_CLOCKSOURCE_SMCLK,
TIMER_CLOCKSOURCE_DIVIDER_1,
period,
TIMER_CAPTURECOMPARE_REGISTER_0, // P1.7/TA1.0 uses register 0
TIMER_OUTPUTMODE_RESET_SET,
dutyCycle
);
I know I can use interrupts to generate the signal, and I've done it for low frequencies. But this signal must be around 500KHz, and with an 8MHz clock, that ain't gonna happen with an interrupt handler.
Am I out of luck with this pin? Is there a solution without reworking the board to swap with another pin that allows PWM?
Thanks,
Rich