Can MSP430F2418 Change the Clock Source of ACLK
Posted: June 1st, 2017, 5:35
Good day,
The MCU is MSP430F2418 which I bought from site: [spam link removed] and at the beginnning, clock source is serve as VLO in MCU inside. I want to change the clock source of ACLK to be crystal oscillator--32768 outside when operating. The code is given below:
The programs,However, always lies in these code “ while(i) { i--;}”. When I deleted the sentence “BCSCTL3 = (XT2S_2+LFXT1S_0+XCAP_1);”, it can operate normally again ! ! ! Why?
Best regards~
The MCU is MSP430F2418 which I bought from site: [spam link removed] and at the beginnning, clock source is serve as VLO in MCU inside. I want to change the clock source of ACLK to be crystal oscillator--32768 outside when operating. The code is given below:
- Code:
#include "msp430.h"
void main(void)
{
unsigned long i=0xffff;
_BIC_SR(0xFFFF); //reset anything in SR, inline function.
WDTCTL=WDTPW+WDTHOLD; //colse watchdog timer
BCSCTL1&=~XT2OFF; /open XT2
BCSCTL2 |= (SELM_2+DIVM_2+SELS); //MCLK、SMCLK choose xt2(5MHz,so MCLK=1.25MHz,SMCLK=5MHz
BCSCTL3 |= (XT2S_2+LFXT1S_2+XCAP_1); //6pF capacitor IFG1 &= ~OFIFG;
P5SEL |= BIT4+BIT6;
P5DIR |= BIT4+BIT6;
P1SEL |= BIT4;
P1DIR |= BIT4;
IFG1&=~(WDTIFG+OFIFG+NMIIFG+PORIFG+RSTIFG); //Interrupt flag reset
FCTL3=FWKEY; //ACCVIFG reset
IE1|=OFIE+NMIIE+ACCVIE; //Interrupt initialization Settings
while(i)
{
i--;
}
BCSCTL3 = (XT2S_2+LFXT1S_0+XCAP_1);
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0xFF; i > 0; i--); // Time for flag to set
}
while (IFG1 & OFIFG); // OSCFault flag still set
while(1);
}
The programs,However, always lies in these code “ while(i) { i--;}”. When I deleted the sentence “BCSCTL3 = (XT2S_2+LFXT1S_0+XCAP_1);”, it can operate normally again ! ! ! Why?
Best regards~