Hi,
I have a custom board using the MSP430F5219, and I'm trying to get the LPM4.5 mode working. The code I'm using to enter and exit is below. When it calls goToLPM4_5(), it does seem to stop running, but I don't believe it is actually going to LPM4.5 mode because the Vcore voltage doesn't drop (it stays at ~1.94V), and I need to actually include the ISR that calls main() in order for the pin interrupt to bring it back to main(). My understanding is that the Vcore should drop to 0V and the ISR isn't needed since the pin interrupt in LPM4.5 will cause a BOR.
The HAL_ConfigureHardware() function is called from main() right after disabling the watchdog. (This code is based on the Bluetopia SPPLE stack demo application, and I added the goToLPM4_5() function and some lines to the HAL_ConfigureHardware() function.)
When it does wake up (from whatever low power mode it was in), it doesn't behave as it does from a normal power-on reset. Things run much slower (~1/10th speed) and just don't behave properly.
I tried disabling as many peripherals and interrupts as I could think of, even if they aren't being used (to my knowledge), like RTC, but I still can't seem to get it into LPM4.5 mode. I suspect it's related to the clocks, and I'm not sure I've set those correctly before entering sleep mode.
Any thoughts or suggestions are appreciated.
Thanks
Angelo
void goToLPM4_5() { UCSCTL4 = SELA_1; //reset all GPIOs P1OUT = 0x00;P2OUT = 0x00;P3OUT = 0x00;P4OUT = 0x00;P5OUT = 0x00;P6OUT = 0x00;P7OUT = 0x00;PJOUT = 0x00; P1DIR = 0xFE;P2DIR = 0xFF;P3DIR = 0xFF;P4DIR = 0xFF;P5DIR = 0xFF;P6DIR = 0xFF;P7DIR = 0xFF;PJDIR = 0xFF; //enable Port1 interrupt P1IE |= (BIT4); //interrupt on falling edge P1IES |= (BIT4); //clear interrupt flag P1IFG &= ~(BIT4); //disable other interrupts to prevent it from waking up right after going to sleep P2IE = 0; TA2CCTL0 = 0; //set GIE in case there any pending flags to service __enable_interrupt(); //enable interrupts //Enable LPM4.5 mode // Disable SVS PMMCTL0_H = PMMPW_H; // PMM Password SVSMHCTL &= ~(SVMHE+SVSHE); // Disable High side SVS SVSMLCTL &= ~(SVMLE+SVSLE); // Disable Low side SVS //this turns off the PMM to allow for LPM4.5 PMMCTL0_L |= PMMREGOFF; // set Flag to enter LPM4.5 with LPM4 request //Enter LPM4.5 mode LPM4; } #pragma vector=PORT1_VECTOR __interrupt void Port1_ISR(void) { //this should not run, since LPM4.5 will just RST uC LPM4_EXIT; main(); } void HAL_ConfigureHardware(void) { long int i; /* Configure the default board setup. */ ConfigureBoardDefaults(); //check PMMLPM5IFG flag to see if RST from LPM4.5 if (PMMLPM5IFG & PMMIFG) { //if exited from LPM4.5, unlock IO PMMCTL0_H = PMMPW_H; PM5CTL0 &= ~(LOCKLPM5); } /* Call the MSP430F5438 Experimentor Board Hardware Abstraction Layer*/ /* to setup the system clock. */ StartCrystalOscillator(); SetSystemClock(BT_CPU_FREQ); /* Configure the scheduler timer. */ ConfigureTimer(); //show that we came out of reset setOutput (GREEN_LED, 1); for (i=0;i<10000;i++) asm("nop"); setOutput (BLUE_LED, 1); for (i=0;i<10000;i++) asm("nop"); setOutput (GREEN_LED, 0); for (i=0;i<10000;i++) asm("nop"); setOutput (BLUE_LED, 0); for (i=0;i<10000;i++) asm("nop"); }