|
MSP430的pwm波
单片机源程序如下:
#include
#include "Config.h"
void setpwm1(int a){
TACCR1 = a;
}
void setpwm2(int b){
TACCR2 = b;
}
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0xff; // P4.1 - P4.6 output
P1SEL |= 0xff; // P4.1 - P4.6 TBx options
TACCR0 = 13500; // PWM Period
TACCTL1 = OUTMOD_7; // CCR1 resett // CCR1 PWM duty cycle
TACCTL2 = OUTMOD_7;
TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
setpwm1(1800);
setpwm2(1800);
_BIS_SR(CPUOFF); // Enter LPM0
}
|
|