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

I would like to call hvx function in my custom task.

i using a ble_app_hrs_freertos example, nrf52

I inserted a new custom task.

if(pdPASS != xTaskCreate(main_thread, "MAIN", 32, NULL , 1, &m_main_thread))
{
   APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}		

and in my custom task, called a sd_ble_gatts_hvx function. then i get a hardfault.

but, if i call in interrupt service routine or app_timer service routine, well done.

why?? do the hard fault occur?

i can't understand.

Parents
  • Hi,

    You are creating your custom task with a priority "1!. Which is high and cannot call any sd_xx functions. Because sd_ble_gatts_hvx converts into SVC the ARM Cortex does not allow calling SVC (priority 2) from higher priority task (like your custom task).

    Change the priority to 3 incase you want to make sd_xxx calls from your custom task.

    if(pdPASS != xTaskCreate(main_thread, "MAIN", 32, NULL , 3, &m_main_thread))
    {
       APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
    }
    
Reply
  • Hi,

    You are creating your custom task with a priority "1!. Which is high and cannot call any sd_xx functions. Because sd_ble_gatts_hvx converts into SVC the ARM Cortex does not allow calling SVC (priority 2) from higher priority task (like your custom task).

    Change the priority to 3 incase you want to make sd_xxx calls from your custom task.

    if(pdPASS != xTaskCreate(main_thread, "MAIN", 32, NULL , 3, &m_main_thread))
    {
       APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
    }
    
Children
Related