#include <msp430x41x.h> //系统文件夹内找
#include "main.h" //当前文件夹内找
main( void )
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer to prevent time out reset
Sys_Init();
while(1)
{
if((P1IN&BIT0) == BIT0)
P1OUT |= BIT1;
else
P1OUT &= ^BIT1;
}
}
/*****************************************************************************
* SYS初始化 *
*****************************************************************************/
void Sys_Init(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
/*时钟初始化 //MCLK:2031616Hz*/
FLL_CTL0 |= XCAP14PF; // Configure load caps
SCFI0 |= FN_2; //频率范围
SCFQCTL =30; //N,如不设置默认=31
SCFI0 |= FLLD_2; //D=2,PUC后的默认值=2
//FLL_CTL1 |= FLL_DIV_4; //4分频,P1.5输出:f=32768/4
FLL_CTL0 |= DCOPLUS;//在MCLK前分频 f=D*(N+1)*faclk,2*(30+1)*32768=2031616Hz
/*端口初始化*/
P1DIR |= BIT1 + BIT2 + BIT3+ BIT4+ BIT5 + BIT6+ BIT7;
}
温馨提示:内容为网友见解,仅供参考