Now, I would like to use the LFXT1(3MHz) as the source
Here is the code I had used to setup:
//turn on the oscillator via the status register (SR) for configuration
BCSCTL1 |= XTS; // ACLK= LFXT1 = HF XTAL
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0xFF; i > 0; i--); // Time for flag to set
}
while ((IFG1 & OFIFG)); // OSCFault flag still set?
BCSCTL2 |= SELM_3;
However, code never leaves the do - while loop
If I dont poll for the IFG1 flag, it turns out that the default DCO register value is being used as the clock source frequency
//turn on the oscillator via the status register (SR) for configuration
BCSCTL1 |= XTS; // ACLK= LFXT1 = HF XTAL
_BIC_SR(OSCOFF); // turn on XT1 oscillator <----[add this]
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0xFF; i > 0; i--); // Time for flag to set
}
while ((IFG1 & OFIFG)); // OSCFault flag still set?
BCSCTL2 |= SELM_3;
I have a seemed problem the only thing that a little my code of initialization of the Oscillator is later the following one:
void InitOsc(void)
{
WDTCTL = WDTPW | WDTHOLD; // Paramos el watchdog timer
BCSCTL1 |= XTS; // XT1 ~ high-frequency
_BIC_SR(OSCOFF); // turn on XT1 oscillator
do // wait in loop until crystal is stable
{
IFG1 &= ~OFIFG;
for (ii = 0xFFFF; ii > 0; ii--);
}
while (IFG1 & OFIFG);
BCSCTL1 |= DIVA1 | DIVA0; // ACLK = XT1 / 8 = 1 MHz
IE1 &= ~WDTIE; // desactiva WDT int.
WDTCTL = WDTPW | WDTTMSEL | WDTCNTCL | WDTSSEL | WDTIS1; // use WDT as timer, flag each. 512 pulses from ACLK
IFG1 &= ~WDTIFG; // clear WDT int. flag
while ((IFG1 & WDTIFG)!=0); // cuenta 1024 pulsos XT1
IFG1 &= ~OFIFG; // clear osc. fault int. flag
DCOCTL |= DCO2 | DCO1 | DCO0;
BCSCTL1 |= RSEL2 | RSEL1 | RSEL0; // MCLK = DCO, 8 MHz (MCLK=Reloj de la CPU)
}
But to my I have left you begin in the while:
while ((IFG1 & WDTIFG)!=0);
if somebody knows or you go because it happens me this, would thank him that helps me.