手头有个430的launchpad,还有个5438A的最小系统板,就用这两个结合SBW调试那个最小系统板,板子上面焊的是25M晶振,但是调试的时候发现用25M晶振老是出错,本来led应该闪烁,但是一直亮,但是对MCLK二分频之后就可以正常跑了,代码如下:
#include <msp430x54x.h>
#define uint unsigned int
#define uchar unsigned char
#define CPU_F ((double)12500000)
#define delayus(x) __delay_cycles((long)(CPU_F*(double)x/1000000.0))
#define delayms(x) __delay_cycles((long)(CPU_F*(double)x/1000.0))
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; //关闭看门狗
P5SEL |= 0x0C; // Port select XT2
UCSCTL6&= ~XT2OFF; // Ena××e XT2 even if not used
UCSCTL3|= SELREF_2; // FLLref = REFO
UCSCTL4|= SELA_2; // ACLK=REFO,SMCLK=DCO,MCLK=DCO
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
SFRIFG1 &= ~OFIFG; // Clear fault flags
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
UCSCTL4 |= SELS_5 + SELM_5; // SMCLK=MCLK=XT2
UCSCTL5|=DIVM_1+DIVS_2;
P8DIR=0xff; //P8设置为输出
while(1)
{
P8OUT &= ~(BIT0+BIT1); //P8.0 = 0,LED亮
delayms(1000);
P8OUT |= BIT0+BIT1; //P8.0 = 1,LED灭
delayms(1000);
}
}
求大神告知怎么回事??
此帖出自
小平头技术问答
一周热门 更多>