Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Sleep mode does not work correctly with FreeRTOS SDK 15.3?

Hello, 

I'm trying to implement a sleep mode for my application. Currently it has around 8 tasks.

I need to disable them all + disable some HW, such as GPS module. And wait for ISRs to wake it up from either: GSM module or accelerometer.

There are 2 problems currently: 

1. First as it was mentioned in many tickets before f.e. here, that sleep mode actually does not sleep when all tasks are disabled. 
Device wakes up constantly for unknown event/ISR and goes back to sleep. 
It seems that SD is actually doing some job and constantly wakes up here:

            if (nrf_sdh_is_enabled())
            {
                uint32_t err_code = sd_app_evt_wait();
                APP_ERROR_CHECK(err_code);
            }

In addition, WDG is enabled and even though it configured to freeze in sleep mode, soon it will reset the system.
Additional info:  
- configUSE_TICKLESS_IDLE is enabled

- also SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; instruction is used to indicate DeepSleep

Is there something else that needs to be done to have a correct behaviour in deep sleep mode ?

Here is trace record from SystemView:

After all tasks were suspended ISR triggers constantly after 1-2 ms.

2. Since all tasks use xTaskDelayUntil(), when there is a wakeup ISR that returns system back to normal. Call to
xTaskResume(), makes all those

tasks to execute immediately for all that time that was skipped, which of course breaks the system. Thus the question is what is the correct way to put FreeRTOS system in deep sleep?

  • There is a limitation on that the interrupt variant cc310 does not work correctly with RTOS threads.So for now, it is not possible to use the interrupt variant of this library with FreeRTOS.

    You need to remove the existing libnrf_cc310_0.9.13.a from your project

    Added the same from the ..\external\nrf_cc310\lib\cortex-m4\hard-float\no-interrupts\libnrf_cc310_0.9.13.a

     That will make the Crypto to function normally without generating interrupts.

  • maybe use a soft-float variant if you do not want to use FPU

  • Thanks Susheel, I have just checked and we actaully using "no-interrupts" version, but CRYPTOCELL_IRQn is still pending. I think we will solve it by manually clearing pending ISR, before going to sleep as mentioned in this ticket.

    As for FPU, instead of going for soft-float. Can we just disable and enable FPU ISR's before and after sleep respectively? Will crypto work correctly after these operations?

  • Update. So I have tried to compile with soft float. But it seems that Nordic does not provied possibility to use FreeRTOS with soft-float, which causes error in ..\external\freertos\portable\CMSIS\nrf52\port_cmsis.c

    #error This port can only be used when the project options are configured to enable hardware floating point support.

    So there is no way to use spft-float with FreeRTOS?
  • I think you can safely remove that #error line. 

    It is there for legacy reasons and I am positive that removing that line will have no effect on how FreeRTOS works.

    Please try it and let me know. I have tested removing that line on other different things and it worked ok.

Related