This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
我的芯片为MSP5438A,主频为内部时钟25M,应用的外设为Timer,UART,AD,现在的问题就是如果用32.768K主频,程序运行良好,但是如果用25M,程序会跑飞,我的数组的定义都用了__no_init 定义,而且查看寄存器的话,没有出现看门狗复位,内核电压我也抬升到了level 3 ,我的Clk, Timer,UART,AD的配置如下:
void UCS_Init(void)
{
unsigned int N_FLL=0;
UCSCTL3 |= SELREF_2; // Set DCO FLL reference = REFO 32768HZ
UCSCTL4 |= SELA_2; // Set ACLK = REFO
__bis_SR_register(SCG0); // Disable the FLL control loop
UCSCTL0 = 0x0000; // Set lowest possible DCOx, MODx
UCSCTL1 = DCORSEL_6; // Select DCO range 50MHz operation
N_FLL = 762;//
UCSCTL2 = FLLD_1 + N_FLL; // Set DCO Multiplier for 25MHz
// (N + 1) * FLLRef = Fdco
// (762 + 1) * 32768 = 25MHz
// Set FLL Div = fDCOCLK/2
__bic_SR_register(SCG0); // Enable the FLL control loop
// Worst-case settling time for the DCO when the DCO range bits have been
// changed is n x 32 x 32 x f_MCLK / f_FLL_reference. See UCS chapter in 5xx
// UG for optimization.
// 32 x 32 x 25 MHz / 32,768 Hz = 781250 = MCLK cycles for DCO to settle
__delay_cycles(78125);
// Loop until XT1,XT2 & DCO fault flag is cleared
/*
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
*/
}
unsigned char Fre=2; //主频 1为32768 2为 25M
void TimerB0_Init(void) //1ms定时
{
if(Fre==1)
{
TB0CTL = MC_0; //计数器禁止
// TBCTL|=MC_1+CNTL_0+TBCLGRP_0;
TB0CCTL0 |= CCIE; //中断使能
TB0CCR0 =32; // 1ms定时
TB0CTL = TBSSEL_1 + MC_1 + TBCLR; //SMCLK
}
else if(Fre==2)
{
TB0CTL = MC_0; //计数器禁止
// TBCTL|=MC_1+CNTL_0+TBCLGRP_0;
TB0CCTL0 |= CCIE; //中断使能
TB0CCR0 =60000; // 1ms定时
TB0CTL = TBSSEL_2 + MC_1 + TBCLR; //SMCLK
}
}
void ADC_Init()
{
P6SEL = 0x10; // Enable A/D channel inputs
ADC12CTL0 = ADC12ON+ADC12MSC+ADC12SHT0_15; // Turn on ADC12_A, extend sampling time
// to avoid overflow of results
ADC12CTL1 = ADC12SHP+ADC12CONSEQ_3; // Use sampling timer, repeated sequence
ADC12MCTL0 = ADC12INCH_4+ADC12SREF_7+ADC12EOS; // ref+=AVcc, channel = A3, end seq.
ADC12IE = 0x01; // Enable ADC12IFG.3
// ADC12CTL0 |= ADC12ENC; // Enable conversions
// ADC12CTL0 |= ADC12SC; // Start conversion - software trigger // 使能转换
}