Pulse Width Modulation

61 views
Skip to first unread message

Jessica Shaw

unread,
Oct 1, 2014, 2:41:18 PM10/1/14
to ti-lau...@googlegroups.com
Hi, 

I am new to MSP430 series microcontroller. I am trying to do pulse width modulation. My code is as follows 

#include <msp430.h>

int main(void)
{

WDTCTL = WDTPW + WDTHOLD;                 
TA1CCTL0 = 0x0040;                       
TA1CTL = 0x0110;
TA1CCR0 = 655;
TA1CCR1 = 327;
P2DIR |= 0x02;                            
P2SEL |= 0x02;                            

//TA1CTL = TASSEL_1 + MC_1 + TACLR;       


__bis_SR_register(LPM3_bits);           
// __no_operation();                        
}

MSP430F5438 counts up to 655 with no problem. I get 50Hz time period. The clock is 32KHz. The problem is that MSP is not taking the "TA1CCR1" value "327" into account. "327" suppose to give me 50% duty cycle. I am not able to control the Duty Cycle. The time period is correct 20msec but I have no control over Duty Cycle. Please advise!

jess

Hans Henry von Tresckow

unread,
Oct 2, 2014, 2:57:29 PM10/2/14
to ti-lau...@googlegroups.com
I think the problem is that you never set up TA1CCTL1 to define the output mode for the pin.

--
You received this message because you are subscribed to the Google Groups "TI Launchpad" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ti-launchpad...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Henry von Tresckow (hvontres)
Reply all
Reply to author
Forward
0 new messages