Hi all,
I'm having problems waking from Sleep using the SleepTimer with the PSoC5LP. I am trying to implement an auto-wake feature and would like to use the SleepTimer to wake the device when it has been asleep for 4096ms (max SleepTimer counter).
I implemented the SleepTimer_Interrupt_Sleep demo project on my development board and observed the LED indicating the toggling of the LED at the appropriate period based on the SleepTimer duration. Great. The I proved the component works...
The problem that I encountered is that the counter does not appear to be reset when SleepTimer_Stop() and SleepTimer_Start() are called. In the demo project the SleepTimer component is started prior to the main loop and never disabled. In my application, I want to enable the SleepTimer() component only when I am about to sleep. I don't want the ISR continuously executing while I the application is running. I just want to wake ~4s after going to sleep.
SleepTimer_Start();
CyPmSaveClocks();
CyPmSleep(PM_SLEEP_TIME_NONE, PM_SLEEP_SRC_CTW);
CyPmRestoreClocks();
SleepTimer_Stop();
(My SleepTimer ISR is identical to that of the demo in that it only calls SleepTimer_GetStatus() according to the driver requirements.)
The behavior I observe is when I put the device to sleep the wake period is erratic. It can be anywhere between immediately waking and the ~4s maximum period.
As a test, I moved the SleepTimer_Start() to the initialization section of my application so that it runs constantly as the demo project illustrates. I did this to prove that the SleepTimer ISR is, in fact, being called every 4096ms in my application. I then induced sleep at various times between ISRs and correctly saw the device waking at each ISR execution.
The problem appears to be when I use the SleepTimer_Start() function it is not starting the timer from 0, it is continuing the counter from where SleepTimer_Stop() was called. I have tried issuing SleepTimer_Init(), SleepTimer_SetInterval(SleepTimer__CTW_4096_MS), etc to re-initialize the SleepTimer component, but have not had any success.
How do I start the counter from 0 every time I call SleepTimer_Start()?
Thanks,
Nate