Hello,
I'm implementing FreeRTOS in RA6T2 for the project, and now I have a question about the low power mode,
according the rm_freertos_port_sleep_preserving_lpm (uint32_t xExpectedIdleTime) in rm_freertos_pot/port.c
/** Check if the LPM peripheral is set to go to Software Standby mode with WFI instruction. * If so, change the LPM peripheral to go to Sleep mode. */
if (R_SYSTEM_SBYCR_SSBY_Msk & saved_sbycr) { /* Save register protect value */ uint32_t saved_prcr = R_SYSTEM->PRCR;
/* Unlock LPM peripheral registers */ R_SYSTEM->PRCR = RM_FREERTOS_PORT_UNLOCK_LPM_REGISTER_ACCESS;
/* Clear to set to sleep low power mode (not standby or deep standby) */ R_SYSTEM->SBYCR = 0U;
/* Restore register lock */ R_SYSTEM->PRCR = (uint16_t) (RM_FREERTOS_PORT_LOCK_LPM_REGISTER_ACCESS | saved_prcr); }
I'm wondering if the sleep mode is the one and only LPM can be used in FreeRTOS?
Can I enter Software Standby mode in the project using FreeRTOS?
Thanks.
The environment parameter is as below,
FSP v3.5.0
FreeRTOS v10.4.3-LTS.Patch.2+fsp.3.5.0
Hi Cooper,
While looking for information, I found this app note and in chapter 3.2, it say there that "The LPMapplications do not use RTOS". I'm not sure about it. I hope someone from the RA team can confirm this one.
JBIf this response, or one provided by another user, answers your question, please verify the answer. Thank you!Renesas Engineering Community Moderatorhttps://community.renesas.com/https://academy.renesas.com/https://en-support.renesas.com/knowledgeBase/
Hi,
Currently the tickless idle support in the FSP FreeRTOS port uses the sleep low power mode. This mode is more suited to this purpose as the systick timer keeps running so FreeRTOS can wake up the CPU when a timeout occurs or simple keep time.
If it is acceptable for the RTOS to lose track of time or ignore timeouts then software standby could be used. In this mode the systick timer stops. You will of course need to enable a wake up source to exit software standby mode.
Ian.
Thanks JB.
After reading the reference you provided, I think "The LPM applications do not use RTOS" means that the example project which the document introducing does not include RTOS, but I think the RTOS and LPM can coexist in any project, but I'm not sure about it either.
Thanks for your reply.
Cooper
Hi Ian,
After study some documents about FreeRTOS, I think it is possible to enter Software Standby mode in FreeRTOS.
There are two weak function can be defined by user.
configPRE_SLEEP_PROCESSING( xExpectedIdleTime );
configPOST_SLEEP_PROCESSING( xExpectedIdleTime );
According to my understanding, user can adjust the clock ,closed unused modules, set the register related to the specific low power mode, set xExpectedIdleTime = 0 and enter the LPM in
configPRE_SLEEP_PROCESSING(xExpectedIdleTime )
After wake up from LPM, the program will skip the __WFI() because xExpectedIdleTime = 0,
and then execute the configPOST_SLEEP_PROCESSING( xExpectedIdleTime ).
Is my understanding correct ?
Cooper.
This approach may work if you enable tickless idle support. You will need to take care of the code which switches the low power mode from software standby to sleep when entering LPM under RTOS control.
What I did (without extensive testing) was not to use tickless idle mode but instead to disbale interrupts, stop the scheduler and then enter software standby mode. This worked but as I say I have not perfomred extensive testing.
Thanks, Ian.
I will try to test this in my project.