touch 34 Posted May 7, 2011 Share Posted May 7, 2011 #include void main(void) { WDTCTL = WDTPW + WDTHOLD; // Kill WDT P2DIR |= BIT2 + BIT5; // P2.2 and P2.5 output P2SEL |= BIT2 + BIT5; // P2.2 and P2.5 options select TA1CCR0 = 128; // PWM period TA1CCTL1 = OUTMOD_6; // CCR2 reset/set TA1CCR1 = 32; // CCR1 25% PWM duty cycle TA1CCTL2 = OUTMOD_6; // CCR2 reset/set TA1CCR2 = 6; // CCR2 5~% PWM duty cycle TA1CTL = TASSEL_2 + MC_1 + TACLR; // SMCLK, up mode, clear TAR __bis_SR_register(LPM0_bits); //LPM 0 while(1){ } } Here's some simple code for using TimerA1 to generate 2 PWM signals on the G2553. TimerA0 could also be used, but on the PDIP versions only has two of the three CCR's accessible I believe. jsolarski, gatesphere and gwdeveloper 3 Quote Link to post Share on other sites
bluehash 1,581 Posted May 7, 2011 Share Posted May 7, 2011 Will they be both running at the same dutycycle? I assume so. Thanks for your code. Quote Link to post Share on other sites
touch 34 Posted May 7, 2011 Author Share Posted May 7, 2011 They will both have the same period, but they can each run at different duty cycles, in this case I'm running one at 25% (TA1CCR1) duty cycle and one at 5% (TA1CCR2) duty cycle. bluehash 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.