Part Number: MSP430F5419A
Tool/software: Code Composer Studio
Hi, I have a board which has an external 16Mhz crystal on XT1.
I have code which runs this board either from the internal DCO @ 16Mhz or using the external xtal.
When configured for the external oscillator i'm getting about 350uA more current when in LMP4 mode than with the internal DCO.
Is there something I should be doing to turn off the XT1 before going into LMP4?
void InitXTAL(void)
{
//Set Up Vcore Voltage Level 2 up to 20Mhz
PMM_setVCore(PMM_CORE_LEVEL_2);
#ifdef INT_XTAL
//Configure XTAL IO
GPIOConfigOutputLow(IO_XTAL_XT1_XIN); //XT1 Output Low
GPIOConfigOutputLow(IO_XTAL_XT1_XOUT); //XT1 Output Low
UCSCTL3 = SELREF__REFOCLK; // FLL: REFO
UCSCTL4 = SELA__REFOCLK | SELS__DCOCLK | SELM__DCOCLK; //ACLK: REFO, SMCLK: DCO, MCLK: DCO
UCSCTL5 = DIVS__2; //SMCLK: /2
UCSCTL6 = XT1OFF | XT2OFF; // turn off XT1 and XT2
// Initialize DCO to 16.00MHz
__bis_SR_register(SCG0); // Disable the FLL control loop
UCSCTL0 = 0x0000u; // Set lowest possible DCOx, MODx
UCSCTL1 = DCORSEL_7; // Set RSELx for DCO = 50 MHz
UCSCTL2 = 488u; // Set DCO Multiplier for 16MHz
// (N + 1) * FLLRef = Fdco
// (488 + 1) * 32768 = 16MHz
__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*32*16MHz/32768Hz = 500000 = MCLK cycles for DCO to settle
__delay_cycles(500000u);
#else //Ext XTAL
//Config XTAL IO
GPIODirInput(IO_XTAL_XT1_XIN); //Input
GPIODirOutput(IO_XTAL_XT1_XOUT); //Output
GPIOPeripheralEnable(IO_XTAL_XT1_XIN); //Set XIN as peripheral function which is XT1
GPIOPeripheralEnable(IO_XTAL_XT1_XOUT); //Set XOUT as peripheral function which is XT1
//Enable XT1 with mid drive strength
UCSCTL6 = XTS | XT1DRIVE_1 | XT2OFF;
//XTAL = 16MHz - MCLK 16MHz - SMCLK 8MHz
UCSCTL4 = SELA__REFOCLK | SELS__XT1CLK | SELM__XT1CLK; //ACLK: REFO, SMCLK: XT1, MCLK: XT1
UCSCTL5 = DIVS__2; //SMCLK: /2
#endif
//Make sure ACLK stays on all the time
BitSet(UCSCTL8, ACLKREQEN);
/* Loop until XT1,XT2 & DCO fault flag is cleared */
do
{
// Clear XT2,XT1,DCO fault flags (Reset if still in fault)
BitClear(UCSCTL7, (XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG));
// Clear Oscillator fault flags
BitClear(SFRIFG1, OFIFG);
}
while (BitTest(SFRIFG1,OFIFG)); //Test oscillator fault flag
}