This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Why does the NRF52840 application stops working when i add code to the timeout handler of the application timer?

I have a function which writes data to the external flash which is using a FAT file-system further using block device implementation of the SDK. Whenever I am calling the function in the Application timer timeout handler, the total crashes after 10 to 60 seconds of operation. I also saw an error log as "Softdevice assertion failed". I understand there is timing issues because of which this might be happening. I want to know the right way to synchronize all the small tasks i have in my App. What is the correct way to run all the different peripherals with synchronization and call functions inside the timer handler? 

And how can i program the nrf52840 correctly to do all the tasks when the program in running in the while(1) loop.

  • Hi Rit,

    All app_timer timeout handlers are called from the RTC interrupt handler context. So if the operation takes long, then it is ok to request those operations in the timeout handlers as long as those operations are asynchronous. It looks to me that something in your operation is not letting the softdevice pre-empt your code. That most likely will happen when you are running on a very high priority context. Did you make sure that all your peripheral drivers are running on the interrupt priority NOT reserved by the softdevice as mentioned here? If you have not initialized any priority for the peripheral you are using, it takes a default highest priority of 0 on ARM NVIC, which is reserved only for softdevice and application are not allowed to use this high priority when working with softdevice..

  • Yes, all the peripherals have priority 6 and not 0.
    Is it a stack overflow that's happening? Because the "NO MEMORY" error also came.
    The application timer just stops after 181 seconds even where I don't have any operation in the timeout handler?

  • <debug> nrf_sdh_ble: BLE event: 0x26.
    <debug> app: pm_whitelist_get returns 0 addr in whitelist and 0 irk whitelist
    <info> app: Slow advertising
    <debug> ble_cts_c: BLE event handler called with event 0x26
    <error> app: ERROR 4 [NRF_ERROR_NO_MEM] at /home/user/Documents/nRF5SDK1702d674dde/components/libraries/timer/app_timer2.c:181
    PC at: 0x00029493
    <error> app: End of error report

  • try increasing APP_TIMER_CONFIG_OP_QUEUE_SIZE in your sdk_config.h file, seems like the app_timer2 is queueing too many events into the queue and the queue size needs to be increased

  • No it's not working, Even if i am removing the function from the timeout handler, the system stops exactly after 181 seconds with the following error.

    <debug> nrf_sdh_ble: BLE event: 0x26.
    <debug> app: pm_whitelist_get returns 0 addr in whitelist and 0 irk whitelist
    <info> app: Slow advertising
    <debug> ble_cts_c: BLE event handler called with event 0x26
    <debug> nrf_sdh_ble: BLE event: 0x26.

    this problem started happening when i initialised the SPI peripheral, rtc3, and lfclk() .

Related