This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I'm working on an application which requires two pwm channels. After failing to impliment them in my main code I've written up a simple program to light two led's with different signals to debug the problem, but I'm still not getting the results I want. Here's my code:
#include <msp430g2452.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Kill WDT
P1DIR |= BIT2+BIT4;
P1SEL |= BIT2+BIT4;
TA0CCR0 = 128; // PWM period
TA0CCTL1 = OUTMOD_7;
TA0CCR1 = 20; // Changes in this value are reflected on the LED
TA0CCTL2 = OUTMOD_7;
TA0CCR2 = 80; //Changes in this value make no difference with respect to LED brightness
TA0CTL = TASSEL_1 + MC_1 + TACLR;
__bis_SR_register(LPM0_bits); //LPM 0
while(1);
}
The led attached to pin 1.4 does light, but only to an arbitrary value not related to the value of TA0CCR2. Any ideas?
Hi,
According to table 16 on p. 40 of the G2452 datasheet, you need to also set P1SEL2 |= BIT4; to set P1.4 up as outputting TA0.2. At the moment you are set up to output SMCLK, which is why you are seeing no duty cycle change.
Regards,
Katie
**Attention** This is a public forum