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

CRITICAL_REGION_ENTER()/EXIT() Error

Hi ,

 Have a problem,pls help

Software: nRF5_SDK_15.3.0  (ble_app_hrs_freertos)

Hardware: nRF52832

In the User Appication Code,Using CRITICAL_REGION_ENTER()/EXIT() API,will result in CPU Halted.

As in Figure below:

======================================================================

INT32U __flashRead(INT32U uiSrcAddr, INT32U *puiRtn, INT32U uiNumToRead)
{
osStatus osRtn;
ret_code_t rc;

// CRITICAL_REGION_ENTER();

rc = nrf_fstorage_read(&fstorage,uiSrcAddr, puiRtn, uiNumToRead);
APP_ERROR_CHECK(rc);

// CRITICAL_REGION_EXIT();

return HAL_OK;
}

======================================================================

Parents
  • You cannot have nrf_fstorage_read inside the critical region since CRITICAL_REGION_ENTER will disable the application interrupts including SVC.  

    After that calling nrf_fstorage_read will in turn call SVC with interrupts disabled will create a hardfault.

    If you are trying to make fstorage run in thread safe way, then this is not the correct way to do it.

    You need to have the critical section around the fstorage events. What exactly are you trying to do?

Reply
  • You cannot have nrf_fstorage_read inside the critical region since CRITICAL_REGION_ENTER will disable the application interrupts including SVC.  

    After that calling nrf_fstorage_read will in turn call SVC with interrupts disabled will create a hardfault.

    If you are trying to make fstorage run in thread safe way, then this is not the correct way to do it.

    You need to have the critical section around the fstorage events. What exactly are you trying to do?

Children
Related