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

got "SOFTDEVICE: INVALID MEMORY ACCESS" Error on nRF52840

Hi:  

    We use freeRTOS + tinyUSB + nRF52SDK develope central Application on nRF52840 DK board.

    we enable SoftDevice first(it return NRF_SUCCESS). then init the USB Power event detect.  but run after run vTaskStartScheduler(). it will got "SOFTDEVICE: INVALID MEMORY ACCESS" issue.  the PC is exit app_util_critical_region_exit(),  the  info = 0x01, 

it show the PERREGION[0].SUBSTATWA = 0x00000001.

the  Clock & Power module peripheral 0x40000000 -- 0x40001000 be written.  But all the USB power event handler & detect all by call SoftDevice APIs.

like:

sd_power_usbdetected_enable(true);
sd_power_usbpwrrdy_enable(true);
sd_power_usbremoved_enable(true);

sd_power_usbregstatus_get(&usb_reg);

sd_clock_hfclk_request();

....

The FreeRTOS config:

#define configTICK_SOURCE                                                         FREERTOS_USE_RTC

#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY         0xf

#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY    _PRIO_APP_HIGH

#define configKERNEL_INTERRUPT_PRIORITY                 configLIBRARY_LOWEST_INTERRUPT_PRIORITY

#define configMAX_SYSCALL_INTERRUPT_PRIORITY            configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY

set "#define NRF_CLOCK_ENABLED 1" in the sdk_config.h for FreeRTOS  ticker timer.  

what's right file for use FreeRTOS with SoftDevice for Clock & Power ? 

  • when I add initialize clock before Enable SoftDevice.  like:
    ret_code_t err_code = nrf_drv_clock_init();
    APP_ERROR_CHECK(err_code);

    ...

    err_code = nrf_sdh_enable_request();  // return error here
    APP_ERROR_CHECK(err_code);   

    in nrf_sdh_enable_request(), the  sd_softdevice_enable() return 0x1001(NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION ) .

    from https://devzone.nordicsemi.com/f/nordic-q-a/28063/softdevice_handler_init-returning-nrf_error_sdm_incorrect_interrupt_configuration description,  it can not set Interrupt.  
     

    Question:   what's limit for nrfx/nrf clock/power drivers with SoftDevice?  How the SoftDevice Interrupt Vector takeover exist without cause  NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION  error

  • the reason of call nrf_drv_clock_init() before Enable SoftDevice  is because the vPortSetupTimerInterrupt() call the nrf_drv_clock_lfclk_request(), but it call nrfx_clock_lfclk_start(), it'll write NRF_CLOCK peripheral registers.  caused  "SOFTDEVICE: INVALID MEMORY ACCESS"  issue.

    some config for Clock & Power :

    #define NRFX_CLOCK_ENABLED 1

    #define NRFX_CLOCK_CONFIG_LF_SRC  1

    #define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6

    #define NRF_CLOCK_ENABLED 1

    #define CLOCK_CONFIG_LF_SRC 1

    #define NRF_SDH_CLOCK_LF_SRC 1

    #define CLOCK_CONFIG_IRQ_PRIORITY 6

    #define NRFX_POWER_ENABLED 1

    #define NRFX_POWER_CONFIG_IRQ_PRIORITY 6

    #define POWER_ENABLED 1

    #define POWER_CONFIG_IRQ_PRIORITY 6

    mostly same as ble_app_hrs_freertos example. exception  is the power.

  • Sorry, Found real caused NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION issue. Because we want use tinyUSB in Keil. we are use the "--gnu" compile option.

    but this will cause nrf_section_iter_init() use these codes:  it seem predefined "__GNUC__" macro

     #if defined(__GNUC__) 
    p_iter->p_item = p_iter->p_set->section.p_start;
    if (p_iter->p_item == p_iter->p_set->section.p_end)
    {
    p_iter->p_item = NULL;
    }
    #else

    it'll cause missing disable POWER_CLOCK IRQ by sdh_state_observer_notify(NRF_SDH_EVT_STATE_ENABLE_PREPARE), because it can not found sdh_state_observers/....

Related