Other Parts Discussed in Thread: MSP430F2013
Hi all,
I've been stumped on a niggling problem I was hoping somebody could help me out with. I'm using the IAR dev suite that came with the eZ430-2013 SpiBiWire dev kit.
I'm trying to use TimerA to generate a PWM signal on P2.6 of a MSP430x2013. Here is the code snipet I'm using to setup the DCO, timer and port accordingly. However I'm not getting a PWM output on P2.6 ... what's wrong?
..... <snip> ...
// Configure Timer A to be both a PWM output on P2.6, as well as configuring timer interrupts for a system timer.
void TimerPWMConfigure(volatile unsigned int PWMWidth)
{
// Setup system clock to 12-18.5MHz
BCSCTL1 |= 0xF0 + 15; // RSELx = 15
// Setup the TMRA register
TACTL = ID_0 + TASSEL_2 + MC_3 + TACLR + TAIE; // 0 divider, SMCLK, up-down mode, TMRA clear, TMRA interrupt enabled
// Setup the period CC0 register to PWM period
CCTL0 = CCIE;
CCR0 = PWMPeriod; // PWM Period
// Setup the PWM width CC1 registers
CCTL1 = OUTMOD_6 + CCIE; // CCR1 toggle/set, compare mode
CCR1 = PWMWidth; // CCR1 PWM duty cycle
// Use P2.6 as TA1
P2SEL |= 0x40; // P2.6 as TA1 option
P2DIR |= 0x40; // P2.6 as output
}
// -------------------------------------------------------------------------
..... <snip> ...
As you can see, I have enabled interrupts and I know the timers are going. I can breakpoint in the ISR and check that TAR is counting as it should and that CCR1 is comparing at the correct value set by PWMWidth.
I can even set P2.6 to be a GPIO output and toggle the line in the ISR and I get a PWM, though I'd like it to work free of the CPU. I am able to get P1.1/TA0 and P1.2/TA1 working, just not P2.6 ... so please help if you know what is wrong??
I'm sure its blindingly obvious, but I can't see it ... :)
Thanks in advance.
Regards,
Hemon