Issue integrating SPI peripheral with BLE peripheral (nRF52840, SDK 17.1.0)

Hello,

I have developed a BLE Peripheral application on the nRF52840 (SDK 17.1.0) which works correctly. Later, I tried to integrate/port an SPI peripheral example into the same project.

After merging the two, I started getting the following error at runtime:

<info> app_timer: RTC: initialized. <info> app: SPI example started. <error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at main.c:282 PC at: 0x0003127B <error> app: End of error report

The error seems to occur inside gpiote_init() when initializing the BHI360 sensor interrupt.

I also noticed potential issues with the SoftDevice and application memory addresses. My current memory layout in the linker file is:

FLASH_PH_START=0x0 FLASH_PH_SIZE=0x100000 RAM_PH_START=0x20000000 RAM_PH_SIZE=0x40000 FLASH_START=0x27000 FLASH_SIZE=0xd9000 RAM_START=0x20002ae8 RAM_SIZE=0x3d518

Has anyone faced a similar problem when combining BLE + SPI in the same project?
Could this be related to GPIOTE driver initialization conflicts, or incorrect SoftDevice memory layout settings?

Any guidance or best practices for combining BLE peripheral (NUS) with an SPI peripheral driver would be greatly appreciated.

Thanks in advance!

  • Hi, 
    Please be aware that NRF5 SDK is deprecated and has no development since 2020. We strongly suggest to move to our new platform nRF Connect SDK. 

    Please try to step into the code and debug. For example you can check what at line 282 in main.c . You can step into the code and check why it returns NRF_ERROR_INVALID_STATE . Most likely the function was called multiple times (The driver was already initialized) causing the error. But in that case you can just ignore the error or remove the second call. See the description of the function here: 

Related