I have been experiencing a problem in which my application will not enter power mode 2 sleep (using sleep timer or input interrupt to wake) . This application is the second I've build and is based upon and shares much code with a previous application that correctly entered PM2.
I am using a CC2541 with BLE 1.4 and IAR 8.20.1 (I have replaced PCON = halSleepPconValue with asm("MOV 0x87,halSleepPconValue") in hal_sleep.c). I am using an external 32MHz crystal and the internal 32kHz RC oscillator (when sleeping). My application periodically awakes from sleep every 2 seconds to make measurements. I can see this happening by placing a scope probe on the XOSC pins - the crystal oscillates for the few milliseconds while measurements occur, and then it stops while sleeping for the remainder of the 2 seconds. The problem seems to be that the core voltage regulator is not shutting down, as a result the power draw is about 2-3mA instead of microamps (I can see the 1.85V regulator holding constant, instead of turning off in unison with the crystal oscillations). As I mentioned previously, my other app behaves as expected, with the crystal and the regulator shutting down for the majority of the 2 second poll loop.
Using the debugger, I can see the code enter halSleep() with halPwrMgtMode getting set to 2 (PM2) and halSleepPconValue getting set to 1. Before the call to HAL_SLEEP_SET_POWER_MODE() (which calls halSetSleepMode()), the power mgmt registers are as follows:
SLEEPSTA = 0x2D, SLEEPCMD = 0x06, CLKCONSTA = 0xC9, CLKCONCMD = 0xC9, PCON = SRCRC = CLD = 0x00
I can't seem to figure out what is going wrong here, as everything seems to be correct, yet the regulator is not turned off (I guess it is entering PM1 instead of PM2). Is there so key setting I am missing that is keeping it from entering PM2? It doesn't seem like my application code should be causing this issue, and the fact that one of the two extremely similar apps sleeps correctly and the other doesn't means I must have some interrupt, pin, timer, etc configured differently between the two and that is the hangup.
Any help here would be greatly appreciated.
Thanks,
Mark