Currently I am attempting to use the Sleep Timer on the CC2541 in order to prevent my device from getting stuck in PM2 sleep for too long.
The way I am attempting to accomplish since the WDT does not run during PM2 is to use the Sleep Timer. From my understanding the Sleep Timers 32KHz is running at all times with the exception of PM3.
I have enabled the Sleep Timer Interrupt with the following code:
#pragma vector = ST_VECTOR
__interrupt void sleepTimerEvt_ISR(void)
{
STIF = 0;
//Reset Device
//HAL_SYSTEM_RESET();
}
void SimpleBLEPeripheral_Init( uint8 task_id )
{
// Enable global interrupts
EA = 1;
//Setup Sleep Timer Configurations
//Disable Sleep Timer Capture Control Functionality
STCC = 0x18;
STIF = 0;
STIE = 1;
//Write Compare Value of Sleep Timer to be = 480K Clks = 15s @ 32kHz CLK
//ST2 = 0x07;
//ST1 = 0x53;
//ST0 = 0x01;
ST2 = 0x08;
ST1 = 0x00;
if (!STLOAD_LDRDY)
{
while(!STLOAD_LDRDY)
{
ST0 = 0x01;
}
}
else
{
ST0 = 0x01;
}
}
I get an interrupt as soon as the Sleep Timer Interrupt is enabled, also I am expecting this to take around 15s due to the configurations I have and due to it being based off of the 32KHz OSC. It constantly triggers an interrupt when running through debugger without even taking a second between triggers.
Am I missing something simple? Any suggestions would appreciated.
Thanks,
Peyton