Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

TWI NRFX problem

Hello. I have a problem with enabling nrfx module. I get this error during prohect compilation:
'NRFX_TWI0_INST_IDX' undeclared here (not in a function); did you mean 'NRFX_TWI_INSTANCE'?

I've included in project: nrf_drv_twi.c, nrfx_twi.c, nrfx_twim.c.
I've enabled in sdk_config.h:

// <e> NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver
//==========================================================
#ifndef NRFX_TWIM_ENABLED
#define NRFX_TWIM_ENABLED 1
#endif
// <q> NRFX_TWIM0_ENABLED - Enable TWIM0 instance

#ifndef NRFX_TWIM0_ENABLED
#define NRFX_TWIM0_ENABLED 1
#endif



// <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

// <e> TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer
//==========================================================
#ifndef TWI_ENABLED
#define TWI_ENABLED 1
#endif


// <e> TWI0_ENABLED - Enable TWI0 instance
//==========================================================
#ifndef TWI0_ENABLED
#define TWI0_ENABLED 1
#endif
// <q> TWI0_USE_EASY_DMA - Use EasyDMA (if present)

#ifndef TWI0_USE_EASY_DMA
#define TWI0_USE_EASY_DMA 1
#endif



What's wrong?

I use nrf52810, SDK 15.3

Parents
  • Hi,

    NRFX_TWI0_INST_IDX is made by the NRFX_TWI_INSTANCE macro based on the configuration in sdk_config.h. I cannot say for sure without knowing more about your code and your full sdk_config.h.

    A typical issue if you want to use nrfx directly is that the configuration macros are being replaced by the legacy driver configuration if it is also present in sdk_config.h. (This is done by apply_old_config.h - see this thread for details). The simplest (and therefore best) solution in most cases is to use the legacy drives and the legacy driver configuration macros in sdk_config.h.

  • Hi. Thanks for the answer. It seems that I already read this thread. For me it's not clear what do you want to see from my "sdk_config.h" file. I attached full file.6180.sdk_config.h
    As I've showed in main post of this thread I've enabled old driver (TWI_ENABLE...) and enabled new nrfx driver (NRFX_TWI..), but NRFX_TWI_INST_ID0 still undefined. 

    Regarding what you're are talking about file "apply_old_config.h". Do I need this file if I want to use only new drivers nrfx? If yes, so for what?

    I also want to stress, that I previously have the same problem for timer and for pwm drivers, but when I enable, together with new nrfx defines, old defines of this drivers in sdk_config.h

  • The problem is solved. The problem is that I call NRFX_TWI_INSTANCE instead NRFX_TWIM_INSTANCE. So, if you want use twi with dma, you should use nrfx_twim driver. It's easy to forget when you look on examples/peripheral and trying to chagne it from nrf_drv to nrfx. In sdk_config.h I've disable nrfx_twi, and left enabled only nrfx_twim and twi, use easydma. Also, I've removed nrf_twi.c from project. Anyway, can you answer on my previous questions:

    Regarding what you're are talking about file "apply_old_config.h". Do I need this file if I want to use only new drivers nrfx? If yes, so for what?

Reply
  • The problem is solved. The problem is that I call NRFX_TWI_INSTANCE instead NRFX_TWIM_INSTANCE. So, if you want use twi with dma, you should use nrfx_twim driver. It's easy to forget when you look on examples/peripheral and trying to chagne it from nrf_drv to nrfx. In sdk_config.h I've disable nrfx_twi, and left enabled only nrfx_twim and twi, use easydma. Also, I've removed nrf_twi.c from project. Anyway, can you answer on my previous questions:

    Regarding what you're are talking about file "apply_old_config.h". Do I need this file if I want to use only new drivers nrfx? If yes, so for what?

Children
No Data
Related