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 */

/* Clear to set to sleep low power mode (not standby or deep standby) */

/* Restore register lock */

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?


Top Replies

Parents Reply Children
  • Hi ,

    While looking for information, I found this app note and in chapter 3.2, it say there that "The LPM
    applications do not use RTOS". I'm not sure about it. I hope someone from the RA team can confirm this one.

    If this response, or one provided by another user, answers your question, please verify the answer. Thank you!
    Renesas Engineering Community Moderator

  • 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.


  • 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.


  • Hi Ian,

    Thanks for your reply.

    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 ?



  • Hi 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.

            /* Re-start the one-shot timer used to wake from software standby mode */
            err = R_AGT_Start(&g_timer_agt1_ctrl);
            if (FSP_SUCCESS != err)


            /* Stop the FreeRTOS scheduler */
            /* Enter software standby mode */
            err = R_LPM_LowPowerModeEnter(&g_lpm0_ctrl);
            if (FSP_SUCCESS != err)
            /* Re-enable interrupts */

            /* Restart the FreeRTOS scheduler */
            (void) xTaskResumeAll();


  • Thanks, Ian.

    I will try to test this in my project.