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

Conflicts when accessing peripherals from mesh-callback

Hi

I faced problems when handling messages from the callback function of the mesh (generic_set_cb() in my case)
we are using generic SDK 15.2 and mesh
SDK 3.1

 Here what I do:
    - directly inside the callback function generic_set_cb() I analyze the message and send an answer back to the sender.   

Normally this works well.

 A problem occurs, when I access the SPI interface from this callback function.

  • the callback from the SPI is never being handled if the message comes from the mesh.
  • if I do the same thing but triggered from the UART-interface, access to SPI works without any problem.

As I read in other posts, this is a priority problem. => therefore I tried to increase the priority of the SPI => no improvement

Next step:

  1. in the callback function generic_set_cb() I store the message and set a flag. Then I leave the callback.
  2. in the main() loop I test this flag
    1. if set: handle the received message (and reset the flag)
    2. access SPI
    3. send an answer back to the sender over the mesh

    Result:

  • SPI handling works fine
  • mesh assert when sending the answer

with the help of the Call Stack I tried to find the root cause of the assert.
As a hint to you where my problem is:

        THIS UGLY HACK (in bearer_event.c) WOULD SOLVE MY ISSUE:

        => if I comment the interrupt prioriry test and fix return a 1, my program works fine!!

bool bearer_event_in_correct_irq_priority(void)
{
    volatile IRQn_Type active_irq = hal_irq_active_get();
    if (active_irq == HAL_IRQn_NONE)
    {
        // return (m_irq_priority == NRF_MESH_IRQ_PRIORITY_THREAD || !hal_irq_is_enabled(EVENT_IRQn));
        return 1;   //HACK!!! not testing irq
    }
   else
   {
       volatile uint32_t prio = NVIC_GetPriority(active_irq);
       return (prio == m_irq_priority || (prio > m_irq_priority && !hal_irq_is_enabled(EVENT_IRQn)));
   }
}

 Questions:

kind regards

Thomas   

Parents Reply Children
No Data
Related