This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Tickless mode with RTX 4.80

Hello everybody,

I am engineering a power constrained application on an STM32L151VC with RTX 4.80. In order to save power we want to sleep as often as it makes sense. The following code is the concept of how we want to use the idle task because of power saving:

uint32_t slept = 0;
uint32_t maxSleepTime = os_suspend();

if(maxSleepTime >= SLEEP_THRESHOLD)
{
   uint32_t start = 0, end = 0;

   start = RTC_GetTicks();

   SetWakeupTimer(maxSleepTime);

   sleep();

   end = RTC_GetTicks();

   slept = end - start;
}

os_resume(slept);

The SLEEP_THRESHOLD is there because the RTC has got a resolution of just 8ms.

It seems like there is a problem when the if is not taken and the code goes from os_suspend(); to
os_resume(0);
several times within a short period.
there is a jump in the os_time variable. The counter increases from 1second to 23seconds within much less than 10 seconds. Within this time I don't get inside the if-clause (breakpoint).
The whole os-timing is wasted and I get a lot of errors because of that (timeouts).

when I replace the code with

for(;;);


the timing and the application is all right.

What am I doing wrong? Where does that increase of os_time come from?
Any ideas on how I can make the code work?

Thanks for you Help
Alexander

  • I got the solution:

    I configured the systick with "the IMPLEMENTATION DEFINED external reference clock." which is Sysclock/8 on an STM32.

    When RTX disables or enables the systick it simply overwrites the SysTick Control and Status Register with default values. Within this procedure it disables the clock divider and the systick is 8 times faster than it should be...

    Configuring the systick without the prescaler and adopting the reload value to that solved the problem.