Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 5, 3 & 1 Forum Discussions

Anonymous
Not applicable

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

0 Likes
1 Solution
Bob_Marlowe
Level 10
First like given 50 questions asked 10 questions asked
Level 10

The CTW (Central Time Wheel) is running continuously, you just can specify at which interval an interrupt is generated. From the description you can see that the first interrupt can be as short as 1 ms until up to the desired period.

   

 

   

Bob

View solution in original post

0 Likes
2 Replies
Bob_Marlowe
Level 10
First like given 50 questions asked 10 questions asked
Level 10

The CTW (Central Time Wheel) is running continuously, you just can specify at which interval an interrupt is generated. From the description you can see that the first interrupt can be as short as 1 ms until up to the desired period.

   

 

   

Bob

0 Likes
Len_CONSULTRON
Level 9
1000 replies posted 750 replies posted 500 likes received
Level 9

Anon,

I realize this is a old post.

I ran into a very similar problem and I 'fixed' the issue in my application.

To prevent the accumulation of SleepTimer counts between using the SleepTimer I stopped the ILO.

Stopping the ILO prevented further SleepTimer counting UNTIL the ILO is restarted.

There are two system API calls involved:

  • CyILO_Start1K()
  • CyILO_Stop1K()

This works very reliably.  You have to judge whether turning off the ILO will prevent other functions in your application from working.

Note:  Creating a low-frequency clock (< 1000 Hz) might automatically assign the ILO as the source.  This might be a problem for you.   You can look at the source clocks used when you view "DWR/Clocks"

This can be changed to a BUS_CLOCK derived source fairly easily.

 

Len
"Engineering is an Art. The Art of Compromise."
0 Likes