msp430系统时钟设置问题,led闪烁观察现象,贴一下代码,很简单的,求好心人解答,分真的没了,求解a ... 5
#include"msp430x14x.h"unsignedchari=0,k=1;voiddelay(unsignedintz){while(z--);}voidmai...
#include"msp430x14x.h"
unsigned char i=0,k=1;
void delay(unsigned int z)
{
while(z--);
}
void main()
{
P2DIR=0xff;P2OUT=0xff;
WDTCTL=WDTPW+WDTHOLD;//关闭看门狗
BCSCTL1&=~XT2OFF; //启动XT2
do
{
IFG1 &= ~OFIFG; //清除晶振失败标志
for (i = 0xFF; i > 0; i--); //等待8MHz晶体起振
}
while ((IFG1 & OFIFG)); //晶振失效标志仍然存在?
BCSCTL2 |= SELM_2 + SELS; //设置SMCLK为8m晶振,八分频
BCSCTL2 |= DIVM_3+DIVS_3; //设置MCLK为8m晶振,八分频
while(1)
{
P2OUT=0xff;
delay(50000);
P2OUT=0xf7;
delay(50000);
}
} 展开
unsigned char i=0,k=1;
void delay(unsigned int z)
{
while(z--);
}
void main()
{
P2DIR=0xff;P2OUT=0xff;
WDTCTL=WDTPW+WDTHOLD;//关闭看门狗
BCSCTL1&=~XT2OFF; //启动XT2
do
{
IFG1 &= ~OFIFG; //清除晶振失败标志
for (i = 0xFF; i > 0; i--); //等待8MHz晶体起振
}
while ((IFG1 & OFIFG)); //晶振失效标志仍然存在?
BCSCTL2 |= SELM_2 + SELS; //设置SMCLK为8m晶振,八分频
BCSCTL2 |= DIVM_3+DIVS_3; //设置MCLK为8m晶振,八分频
while(1)
{
P2OUT=0xff;
delay(50000);
P2OUT=0xf7;
delay(50000);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询