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

Intermittent HardFault crash in timer_list_remove

I am currently using SDK 12.1.0 and experiencing intermittent HardFault crashes in timer_list_remove() with the stack indicating the origin being a SWI0_IRQHandler call.

In order to minimise race-conditions, timing-windows, need for critical sections etc. I am using the App Scheduler so that as much of my work as possible is done off the main loop - my app timers are also scheduler based so I'm using both:

APP_TIMER_APPSH_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, true);

and

APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);

The timers are normally working absolutely fine. I do also, at certain times, use nrf_delay_us() from the main loop and I notice that a call to that results in a call to timer_list_remove (via SWI0_IRQHandler )

The majority of app timer usage is done entirely in the main loop. However, for one particular timer, I have one call to app_timer_start() and one to app_timer_stop() from within the ble_evt_dispatch() callback (i.e. as registered with softdevice_ble_evt_handler_set() at startup).

Should those app_timer calls be made via a scheduled callback instead? I can easily make the change but I want to make sure that it is currently definitely wrong, and that I am fixing the problem for sure - and not just potentially changing timing and therefore when the crash may occur.

Any thoughts?

Related