How to control fall into SLEEP mode

mrazoun wrote on Tuesday, October 25, 2016:

sorry for beginner’s questions. How is it possible to control falling into SLEEP mode ?

When I’m using the peripheral (for example UART) which is not working in SLEEP mode I have to inform somehow FreeRTOS that the task need uP in RUN. Now I made it through proper setting of constant configEXPECTED_IDLE_TIME_BEFORE_SLEEP and parameter “xTicksToWait” in function ulTaskNotifyTake().
After that it depends on condition “if( xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP )” (function portTASK_FUNCTION() in task.c) if uP goes into SLEEP or not.
Is it possible only by this way ?

My setup : EFM32GG (Cortex-M3), FreeRTOS_LowPowerTickManagement_BURTC.c, FreeRTOS V8.2.3, SLEEP = EM2
Thank’s in advance.

rtel wrote on Tuesday, October 25, 2016:

In FreeRTOS_LowPowerTickManagement_BURTC.c you will see a function
called vPortSuppressTicksAndSleep() which handles the entry into and out
of sleep mode.

In that function you will see a call to SLEEP_Sleep() - which if I
recall correctly is a call into the SiLabs library, and the library
function should not put the MCU into a sleep mode that is too low for
the peripherals being used. So the first question is, did you use the
SiLabs library functions to initialise the UART? If so, why does the
sleep manager not know that it cannot go into a sleep mode lower than
the minimum the UART can use?

Just above there you will see a macro called
configPRE_SLEEP_PROCESSING() being called. That allows you to insert
any code you want, and if the code the macro executes decides you should
not go into sleep mode then set its parameter (xModifiableIdleTime) to
zero and you will not go into sleep mode. Note this is a macro, not a
function, so in the macro’s implementation you have to access the
xModifiableIdleTime variable directly.

mrazoun wrote on Wednesday, October 26, 2016:

Thank’s for your very heplfull message. Now I understood this and I will modify my source code according to your explanation.