Hello there,
I'm relatively new to STM32- and RL-ARM-Programming. I'm using Keil, the STM32F107VC-controller, the standard peripheral library and the RTX-Kernel.
I am developing a device, which will work user driven: Only when the user pushs a button, the system has to work a short time. Beside that, every 10 to 20 seconds some device states (e.g.: battery status) have to be checked.
So the device will mostly wait for user input in the os_idle_demon()-task. To save power, I want to put the controller into sleep-mode. Therefore, I'm calling __WFI() in the endless loop of the os_idle_demon()-task.
My problem is, that __WFI() returns immediately and doesn't wait for any interrupt. I assume, that some OS-timer generate interrupts, so that __WFI() returns immediately. Does anybody has an idea, how I can put the device to sleep reliably? I can't use a stop mode, because I also want to be able to use timer-interrupts.
I wrote a similar code, where I called __WFI() from the main loop (without RTX-support) and it worked fine. So the structure of my code doesn't seem to have failures.
Greetings, Hardy
Ok, I understand. Is there a possibilty to avoid this behaviour, when no interrupt occurs? So the Core really can go to sleep and won't be waken every 10mS. Could the scheduler systick be stopped before calling __WFI() and started after returning from __WFI()?
Now I've found a soulution for my problem:
I've enclosed the __WFI()-command between the calls of "tsk_lock()" and "tsk_unlock()".
tsk_lock(); //Disable RTX System Tick Timer interrupts __WFI(); tsk_unlock(); //Enable RTX System Tick Timer Interrupts.
According to the documentation, these calls disable/enable the system tick timer interrupts. So, during the call of __WFI(), no task switch is possible. But external interrupts or internal (timer-)interrupts still work and wake up the controller.
Do you think, this is a good solution?