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.

Shutdown & restart of LFXT1 on a TMS320F2132

I'm currently designing a board using a TMS320F2132 with an 8.0 MHz crystal, run from 2 AAA cells (i.e. 3v nominal).  I can get the oscillator to run using the standard code

BCSCTL1 |= XTS;

// ACLK = LFXT1 = HF XTAL
BCSCTL3 |= LFXT1S1;  // 3 – 16MHz crystal or resonator
do
{
  IFG1 &= ~OFIFG;
 
// Clear OSCFault flag
 
for (i = 0xFF; i > 0; i--);
 
// Time for flag to set
}
while (IFG1 & OFIFG);  // OSCFault flag still set?

Shutting down the CPU using LPM3 leaves a current drain of about 2 or 3 mA (as LFXT1 is still running), as per the datasheet - this drains the batteries too quickly, so I need to reduce this to as low as possible.

I wish to shut down the crystal oscillator, and use the internal LP/LF oscillator to react to an external push-button on an interruptible port pin (P2.4).  If I clear the XTS bit, with LFXTS1,0 left at 0b10 (as for a 3-16MHz crystal with XTS = 1) the MSP430x2xx family user guide slau144e implies that MCLK, etc run from the VLOCLK. 

Is this the correct way to shut down and restart LFXT1 ?

// Initialization code here

BCSCTL1 &= ~XTS;                     // XTS bit cleared, engaging VLOCLK
_bis_SR_register(LPM4_bits + GIE)        // start LPM4 mode, setting OSCOFF bit and shutting down LFXT1

//
// rest of code after wakeup
//

#pragma

 

 

vector=PORT2_VECTOR

__interrupt

void port2 (void)
{
  _bic_SR_register_on_exit(LPM4_bits);          // exit LPM4 mode
 
if (P2IFG & 0x08)       // Check for correct interrupt
  {
     BCSCTL1 |= XTS; // ACLK = LFXT1 = HF XTAL
     BCSCTL3 |= LFXT1S1;  // 3 – 16MHz crystal or resonator
     do
     {
        IFG1 &= ~OFIFG;
       
// Clear OSCFault flag
       
for (i = 0xFF; i > 0; i--);
      
// Time for flag to set
     }
    while (IFG1 & OFIFG);  // OSCFault flag still set?
 
}
P2IFG = 0;
}

Best regards

Chris

  • Chris,

     

    A couple things:

    1- To change the clock from the HF XTAL to the VLO you need to set the clock to low-frequency mode (i.e. clear the XTS bit) and configure the part for the VLO (BCSCTL3 |= LFXT1S_2). So this implies you will need to clear the bits in the LFXT1Sx portion of BCSCTL3 [5:4] everytime you switch between the two clocks.

    2- The loop you use for the HF XTAL to settle is in an interrupt context. If there is an issue with your XTAL for some reason you will be stuck in the interrupt, unable to recover. You should use the interrupt to exit LMP4 and re-enable the HF XTAL in the main loop.

     

    -Alex

**Attention** This is a public forum