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

What could explain a HardFault when entering in critical region?

Hello,

We are developing an application which is using the app_scheduler (especially to put events etc.)

It seems that sometimes (very rarely) we detected a Hard Fault when the app_scheduler is calling the CRITICAL_REGION_ENTER() macro (into the app_scheduler.c). We have retrieved core registers when the panic appears:

  • The program counter pointed to "sd_nvic_critical_region_enter" from sdk/import/s110_nrf51822/include/nrf_soc.h line 474 where we can find the supervisor call in order to disable irq.
  • IPSR = 0x3 --> HardFault

Any ideas about what could induce this hard fault?

Thx!

Parents
  • Check if you are using APP_TIMER and if you have set RTC1 interrupt handler priority to APP_HIGH, then like RK said it will cause an hardfault in app_scheculer

    below m_evt_schedule_func = app_timer_evt_schedule (set in APP_TIMER_INIT macro)

    RTC1_IRQHandler->timer_timeouts_check()->timeout_handler_exec->m_evt_schedule_func->app_sched_event_put->CRITICAL_REGION_ENTER
    
  • Hello Aryan,

    Thanks for your comment.

    Yes we are using the app_timer and the RTC1 IRQ is always set to LOW.

    But, actually, we have modify the app_timer in order to save RAM consumption, and I found the issue: In our RTC1_IRQHandler, we add CRITICAL_REGION_ENTER when calling "timer_timeouts_check()", so when there is a task to execute, we will perform another CRITICAL_REGION_ENTER in the app_scheduler.

    You routed me to the issue ;) Thx!

Reply
  • Hello Aryan,

    Thanks for your comment.

    Yes we are using the app_timer and the RTC1 IRQ is always set to LOW.

    But, actually, we have modify the app_timer in order to save RAM consumption, and I found the issue: In our RTC1_IRQHandler, we add CRITICAL_REGION_ENTER when calling "timer_timeouts_check()", so when there is a task to execute, we will perform another CRITICAL_REGION_ENTER in the app_scheduler.

    You routed me to the issue ;) Thx!

Children
No Data
Related