上电单片机的端口不稳定,闪动7下,非常有规律,求大神指导啊用P1.2驱动一个贴片LED,观察PWM波形变化
用的如下程序测试的:
#include <msp430x14x.h>
void main(void)
{
WDTCTL = WDTPW +WDTHOLD; // Stop WDT
TACTL = TASSEL1 + TACLR; // SMCLK, Clear Tar
CCR0 = 512-1; // PWM Period = 488uS
CCTL1 = OUTMOD_7; // CCR1 reset/set
CCR1 = 256; // CCR1 PWM duty cycle
CCTL2 = OUTMOD_7; // CCR2 reset/set
CCR2 = 128; // CCR2 PWM duty cycle
P1DIR |= 0x04; // P1.2 output
P1SEL |= 0x04; // P1.2 TA1 option
P2DIR |= 0x01; // P2.0 output
P2SEL |= 0x01; // P2.0 TA2 otion
TACTL |= MC0; // Start Timer_A in up mode
for (;;)
{
_BIS_SR(CPUOFF); // Enter LPM0
_NOP(); // Required only for C-spy
}
}
昨天测试蜂鸣器和流水灯也出现过闪动现象,求大神指导!谢谢 |