How CRITICAL_REGION work in project?

I'm using the nrf52832 wth nrf SDK17.

I defined a linked list to organize my data.

Usually, I add or delete data in ble_evt_handler and operate them in other interrupts.But the boundary violation will happened frequently.

So I think maybe I need to use critical region.

However,I can not evaluate the affect of critical region,whether temporal or logical.

I want to know how critical region work in my project.

Parents
  • Hi, 

    In the nRF5 SDK, the `CRITICAL_REGION_ENTER()` and `CRITICAL_REGION_EXIT()` macros are used to create a critical region where certain sections of code can execute atomically, without being interrupted. This is particularly useful when you need to ensure that a specific operation is not disturbed by other threads or processes. When you enter a critical region using `CRITICAL_REGION_ENTER()`, all peripheral interrupts will be disabled/masked. This means that during the execution of the critical region, no other interrupts can preempt the execution. When you exit the critical region using `CRITICAL_REGION_EXIT()`, the interrupts are re-enabled. See this post

    Regards,
    Amanda H.

  • Hi,

    When peripheral entry critical region,all peripheral interrupts will be disabled/masked.If means the interruption that should have occurred conductively-closed or just be put in a waiting queue that used for interruputions?If it is the latter,the interruption will be called in order?

Reply Children
Related