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 //
#pragma __interrupt void port2 (void) Best regards Chris
_bis_SR_register(LPM4_bits + GIE) // start LPM4 mode, setting OSCOFF bit and shutting down LFXT1
// rest of code after wakeup
//
{
_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;
}