#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P2DIR |= 0x0C; // P2.2 and P2.3 output
P2SEL |= 0x0C; // P2.2 and P2.3 options select
TA1CCR0 = 128; // PWM Period/2
TA1CCTL1 = OUTMOD_6; // CCR1 toggle/set
TA1CCR1 = 32; // CCR1 PWM duty cycle
TA1CCTL2 = OUTMOD_6; // CCR2 toggle/set
TA1CCR2 = 96; // CCR2 PWM duty cycle
TA1CTL = TASSEL_2 + MC_3 + TACLR; // SMCLK, up-down mode, clear TAR
__bis_SR_register(LPM0_bits); // Enter LPM0
__no_operation(); // For debugger
}
此帖出自
小平头技术问答
一周热门 更多>