WFI usage with RTOS
Hi,
I am using STM32F779NI and CMSIS RTOS2 for my project. Software was working well till I added code for low power mode with RTOS tick-less operation as per the link
https://www.keil.com/support/docs/3591.htm
After adding the code in osRtxIdleThread, the soft Timer seems to behave incorrectly. Attaching the respective code snippet.
Software Architecture overview:
After system is turned ON, few tasks are created and a periodic soft timer of 500 ms is created. All tasks are blocking till they get a message in their message queue. The message can be posted from other tasks or via soft timer call backs that is used heavily in our architecture.
Once all the tasks and 500ms Timer are created, then a 6ms periodic timer is created. In the callback of this 6ms Timer, message is posted in one of the high priority task's message queue. With this message reception, this task performs important activities like sensor sampling/polling data etc. every 6ms.
Note: Soft Timer task priority is higher than this task i.e. Timer task priority is osPriorityHigh and this task's priority is osPriorityAboveNormal4.
Also, here a periodic soft timer of 300 ms is created which is for used for a short time of around 20 sec with frequency 300ms. Then it is deleted.
Problem Statement:
The soft timers looks to be signalled more than the required after oskernelResume().
I have printed HAL_GetTick() in the callback of 6ms Timer and 500ms Timer. Note that HAL_GetTick() returns osKernelGetTickCount().
The problem is when I see the printed tick value, consecutive values are 6ms difference apart that is correct, but the value is not as per the real-time.
For a 27 sec log value taken, tick value printed should be around 27000 ms but it went up to 74225 ms. Same behavior for 500ms timer as well.
Note: Both 6ms Timer and 500ms Timer will always run till system is turned Off. I understand oskernelResume compensate for OS tick and timer tick, but with value printed looks like it is over compensating, maybe it is signalled more times. What could be the reason for this?
Any thing to consider for ISR and thread, timer callback execution when using osKernelSuspend, osKernelResume with WFI?
Note: RTC auto wakeup is configured in interrupt for CPU wakeup.
Adding code snippets below.
