chulen 0 Posted October 16, 2012 Share Posted October 16, 2012 Hi all, this is my first post in this forum. I am new to C programming and I managed to produce a variable frequency - variable duty cycle. I did it with the following code. #include void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT BCSCTL1 = CALBC1_16MHZ; // Set DCO to 16MHz DCOCTL = CALDCO_16MHZ; P1DIR |= BIT2; // P1.2 to output P1SEL |= BIT2; // P1.2 to TA0.1 CCR0 = 16-1; // PWM Period CCTL1 = OUTMOD_7; // CCR1 reset/set CCR1 = 1; // CCR1 PWM duty cycle TACTL = TASSEL_2 + MC_1; // SMCLK, up mode _BIS_SR(LPM0_bits); // Enter LPM0 } However, I can't understand how to produce different duty cycle in different ends (same frequency). I will need about 5 different duty cycles. Any ideas on how to solve this? Thanks in advance. Quote Link to post Share on other sites
Rickta59 589 Posted October 17, 2012 Share Posted October 17, 2012 http://www.ti.com/lit/an/slaa513/slaa513.pdf Quote Link to post Share on other sites
chulen 0 Posted October 17, 2012 Author Share Posted October 17, 2012 Thank you very much. Quote Link to post Share on other sites
chulen 0 Posted October 20, 2012 Author Share Posted October 20, 2012 Hi again. I'm having trouble with my MSP430G2553, as I want to have 6 different outputs. They all have to work at the same frequency, but the times at which they are on are different. For instance, what I want is described in the attachment. Is this possible? I have read that there are three registers for Timer A, but I have read that there are more timers such as Timer A1, and Timer B. Can I use these? If not, is there any possible way to get six signals out of the MSP? Thanks a lot for your time. Quote Link to post Share on other sites
jsolarski-backup 22 Posted October 21, 2012 Share Posted October 21, 2012 yes you can get 6 outputs, you can use a software pwm, or use a shift register. but look on this forum for controlling multiple servos. i would.link to it but I'm on my phone. Quote Link to post Share on other sites
gordon 229 Posted October 21, 2012 Share Posted October 21, 2012 viewtopic.php?f=10&t=2207 viewtopic.php?f=10&t=2240 Quote Link to post Share on other sites
pabigot 355 Posted October 21, 2012 Share Posted October 21, 2012 And viewtopic.php?f=10&t=2274, just for completeness. The referenced bug in mspgcc has long been fixed. gordon 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.