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

identifier "NRFX_TWI0_INST_IDX" is undefined

Hi All,

I have developed my application for the nRF52832 (SKD15.2) on top of the TWI sensor example. I moved from the legacy TWI driver to nrfx due to the data length limit in the TX and RX functions. This example obviously does not use softdevice.

Everything works great in this application for both my TWI sensors (fuel gauge and IMU). 

Now, moving this code over to my other fully functional BLE peripheral code, i run into this error. "error:  #20: identifier "NRFX_TWI0_INST_IDX" is undefined"

It is telling me that this static nrfx_twi_t p_twi_instance = NRFX_TWI_INSTANCE(0); is undefined. However, i have gone through the sdk_config.h file and ensured that everything related to TWI is the same as my original sensor example. 

Is there some conflict here between nrfx_twi and Softdevice?

Cheers,

Zoran

  • Hi,

    Which IDE are you using? In addition to adding it in the project sdk.config file you would also have to add the file to the project and add the path to where the file resides to the user include directories ( if using SES) . 

    regards

    Jared 

  • Hi Jared,

    Thanks for the feedback. I am using Keil. I have added the file to the project and added the path in the include directories. It is very strange that the compiler does not like switching to NRFX. the legacy TWI driver works fine with my BLE code. I just don't understand what could be the issue.

  • Hi Jared,

    I just tested this on the ble_app_blinky app. The goal is to use NRFX_TWI.

    I added the following:

    (1) #include "nrf_drv_twi.h" (added this header to main.c)

    (2) included "nrfx_twi.c" to the project

    (3) selected the following in sdk_config.h

    // <e> NRFX_TWI_ENABLED - nrfx_twi - TWI peripheral driver
    //==========================================================
    #ifndef NRFX_TWI_ENABLED
    #define NRFX_TWI_ENABLED 1
    #endif
    // <q> NRFX_TWI0_ENABLED - Enable TWI0 instance

    #ifndef NRFX_TWI0_ENABLED
    #define NRFX_TWI0_ENABLED 1
    #endif

    (4) in main.c I add static nrfx_twi_t m_twi = NRFX_TWI_INSTANCE(0); 

    This produces the error: identifier "NRFX_TWI0_INST_IDX" is undefined

    I am not sure if i have missed a step here. But any help would be greatly appreciated.

    Cheers

  • Hi,

    Comparing the twi_sensor and ble_app_blinky project I see that you would need the to do the following:

    1. #include "nrf_drv_twi.h" to main.c
    2. Add the following source file and file path to the project:
      1. nrf_drv_twi.c
      2. nrfx_twim.c
    3. Add the following to the config file:
      1. #define NRFX_TWIM_ENABLED 1
        #define NRFX_TWI_ENABLED 1
        #define TWI0_ENABLED 1
        #define TWI0_USE_EASY_DMA 1
Related