Jump to content
43oh

Dual PWM with TimerA1


Recommended Posts

#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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...