FreeRTOS with stop2 mode using rtc for wakeup

'm working on a project with the STM32L4 series freeRTOS with tickless idle mode for stop2. , and to wake up the device, I’m using RTC.

Within my project, there are four tasks. Three of the tasks run by default, and the fourth task has the ability to enter stop2 mode. However, it isn’t functioning to do so.

Which methods is used for achieving these functionality?

thank you

Hello @Qaisar,

Probably best to use tickless idle and then implement configPRE_SLEEP_PROCESSING() to induce STOP2 whenever your application wants to use STOP2. All of your tasks will need to be idle for the idle task to run and induce a tickless idle period, which is how you will get into STOP2.

Can you tell us more about the application? Under what circumstances do you want to use STOP2?

thank you @jefftenney for you response.
In my project.
The first Task in my project is to turn on the LED.
The second Task is to get data from the sensor and notify the third sensor so the third send data to the server and notify the forth task.

here the forth task the device to go into sleep mode. first I deinit all the modules like gpio and adc etc, then halt the systick and Hal clock and its working. the code is,
void SleepModeTask(void argument)
Infinite loop */
// osSemaphoreAcquire(rangSempHandle, osWaitForever);
// osThreadSuspend(NULL);

SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;

SysTick->CTRL  |= SysTick_CTRL_TICKINT_Msk;


Is it a good approach? when i use the tickless idle it require to call the osDelay() and also require that all task should be idle state so if you @jefftenney give me a good it wil also be appreciated.
thank you

As @jefftenney mentioned before, you do not need a separate task for this - you should do this in configPRE_SLEEP_PROCESSING(). Please read this page - Tickless Low power features in FreeRTOS.

@aggarg @jefftenney
I am running freeRTOS in cooperative mode. I don’t want to utilise the osDelay() method for the low power mode.
Therefore, in tickless idle mode, there are requirements for idle tasks, but in my scenario, idle tasks is not even execute.
if i go for tickless mode how i can do it?

Whichever mode you use FreeRTOS in, idle task is always there. Lets say you have n application tasks, you probably want to put your system to sleep when those tasks have nothing to do i.e. those are waiting for an event to happen. At that point, the idle task will run and you can put your system to sleep. Is there a problem in letting the idle task run when there is no application task to run?

thank you for your response.
can you guide how to implement the scenario that you are telling?
because in previous comment that i implement stop2 mode in which current consumption is about 82 microAmps but it should be 7 microAmps, not giving the expected resuts.

This amount of extra current consumption could be due to debugging. When debugging, the use of STOP mode usually doesn’t stop the system clock like it would if not debugging.