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

undefined reference to `nrfx_twi_tx'

Hello,

I have a twi module developped using sdk v13. I want to upgrade it to the sdk 15 to integrate it to a mesh project.

I changed all nrf_drv functions to nrfx same with structures.

I enabled TWI in sdk_config.h

i added the following path to my project:

$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/softdevice/s132/headers/
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/softdevice/s132/headers/nrf52/
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/modules/nrfx
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/modules/nrfx/mdk
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/modules/nrfx/hal
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/modules/nrfx/drivers
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/modules/nrfx/drivers/includes
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/modules/nrfx/templates/nRF52832
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/toolchain/cmsis/include
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/toolchain/gcc
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/toolchain/cmsis/dsp/GCC
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/boards
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/integration/nrfx
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/libraries/log
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/libraries/util
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/libraries/delay
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/integration/nrfx/legacy
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/modules/nrfx/drivers/include
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/external/custom_mesh_utilities
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/libraries/experimental_log
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/libraries/experimental_log/src
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/libraries/experimental_section_vars
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/libraries/experimental_memobj
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/libraries/balloc
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/libraries/bsp
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/components/libraries/button
$(SDK_ROOT:../../../../nRF5_SDK_15.0.0_a53641a)/config/nrf52832/config

I still get the error undefined reference to `nrfx_twi_tx'

Any idea of what I am doing wrong?

I am using SES.

Thank you for helping.

Regards,

Mickael

Parents
  • Hello, 

    NRFX_TWI_ENABLED must be set to '1' in your sdk_config.h header. You may use the sdk_config.h from the twi_sensor example in SDK 15 as reference, or have you enabled it already? 

    Regards,

    Vidar

  • Hello,

    thank you for your answer.

    I have already enabled NRFX_TWI_ENABLED in sdk_config.h and i modified it to the following:

    #ifndef TWI_ENABLED
    #define TWI_ENABLED 1
    #endif
    
    #ifndef TWI_DEFAULT_CONFIG_FREQUENCY
    #define TWI_DEFAULT_CONFIG_FREQUENCY 26738688
    #endif
    
    #ifndef TWI_DEFAULT_CONFIG_CLR_BUS_INIT
    #define TWI_DEFAULT_CONFIG_CLR_BUS_INIT 1
    #endif
    
    #ifndef TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT
    #define TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0
    #endif
    
    #ifndef TWI_DEFAULT_CONFIG_IRQ_PRIORITY
    #define TWI_DEFAULT_CONFIG_IRQ_PRIORITY 0
    #endif
    
    #ifndef TWI0_ENABLED
    #define TWI0_ENABLED 1
    #endif

    I still get the errors.

    Regards,

    Mickael

  • I got it.

    I was missing TWI0_USE_EASY_DMA.

    But I now have 'NRFX_TWI0_INST_IDX' undeclared here (not in a function) while doing

    static const nrfx_twi_t _i2c = NRFX_TWI_INSTANCE(0);

    i included the following to that file.

    #include "nrf.h"
    #include "nrfx_twi.h"
    #include "nrf_delay.h"
    #include "nrfx_gpiote.h"
    #include "bsp.h"
    #include "app_util_platform.h"
    

    regards,

    Mickael

  • Thanks for the update. TWI is the legacy implementation (same as used on the 51 series), and it becomes TWIM once you enable easyDMA. Try using NRFX_TWIM_INSTANCE(0) instead.

  • I tried with NRFX_TWIM_INSTANCE(0) as you suggested.

    I included "nrfx_twim.h", and changed the functions and structures from nrfx_twi to nrfx_twim.

    I'm back with "undefined reference to `nrfx_twim_tx'".

    I have NRFX_TWIM_ENABLED and NRFX_TWIM0_ENABLED at the moment, as well as NRFX_TWI_ENABLED and NRFX_TWI0_ENABLED

  • Hi,

    Looks like the TWI legacy configuration needs to be kept, otherwise the NRFX_TWIM_* configurations get undefined by the legacy to nrfx 'translation' layer (apply_old_config.h), hence causing to the undefined reference errors. This is probably not the intended behavior, and have reported it as a bug internally. 

    The configurations below should work if you ise TWIM 0. Notice that both TWI_ENABLED and NRFX_TWIM_ENABLED are set to '1'

    // <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
    
    // <q> NRFX_TWIM1_ENABLED  - Enable TWIM1 instance
     
    
    #ifndef NRFX_TWIM1_ENABLED
    #define NRFX_TWIM1_ENABLED 0
    #endif
    
    // <o> NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY  - Frequency
     
    // <26738688=> 100k 
    // <67108864=> 250k 
    // <104857600=> 400k 
    
    #ifndef NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY
    #define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688
    #endif
    
    // <q> NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT  - Enables bus holding after uninit
     
    
    #ifndef NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT
    #define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0
    #endif
    
    // <o> NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
     
    // <0=> 0 (highest) 
    // <1=> 1 
    // <2=> 2 
    // <3=> 3 
    // <4=> 4 
    // <5=> 5 
    // <6=> 6 
    // <7=> 7 
    
    #ifndef NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY
    #define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 7
    #endif
    
    // <e> NRFX_TWIM_CONFIG_LOG_ENABLED - Enables logging in the module.
    //==========================================================
    #ifndef NRFX_TWIM_CONFIG_LOG_ENABLED
    #define NRFX_TWIM_CONFIG_LOG_ENABLED 0
    #endif
    // <o> NRFX_TWIM_CONFIG_LOG_LEVEL  - Default Severity level
     
    // <0=> Off 
    // <1=> Error 
    // <2=> Warning 
    // <3=> Info 
    // <4=> Debug 
    
    #ifndef NRFX_TWIM_CONFIG_LOG_LEVEL
    #define NRFX_TWIM_CONFIG_LOG_LEVEL 3
    #endif
    
    // <o> NRFX_TWIM_CONFIG_INFO_COLOR  - ANSI escape code prefix.
     
    // <0=> Default 
    // <1=> Black 
    // <2=> Red 
    // <3=> Green 
    // <4=> Yellow 
    // <5=> Blue 
    // <6=> Magenta 
    // <7=> Cyan 
    // <8=> White 
    
    #ifndef NRFX_TWIM_CONFIG_INFO_COLOR
    #define NRFX_TWIM_CONFIG_INFO_COLOR 0
    #endif
    
    // <o> NRFX_TWIM_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
     
    // <0=> Default 
    // <1=> Black 
    // <2=> Red 
    // <3=> Green 
    // <4=> Yellow 
    // <5=> Blue 
    // <6=> Magenta 
    // <7=> Cyan 
    // <8=> White 
    
    #ifndef NRFX_TWIM_CONFIG_DEBUG_COLOR
    #define NRFX_TWIM_CONFIG_DEBUG_COLOR 0
    #endif
    
    // </e>
    
    // <q> NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED  - Enables nRF52 anomaly 109 workaround for TWIM.
     
    
    // <i> The workaround uses interrupts to wake up the CPU by catching
    // <i> the start event of zero-frequency transmission, clear the 
    // <i> peripheral, set desired frequency, start the peripheral, and
    // <i> the proper transmission. See more in the Errata document or
    // <i> Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/
    
    #ifndef NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED
    #define NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0
    #endif
    
    // <e> TWI_ENABLED - nrf_drv_twi - TWI/TWIM peripheral driver - legacy layer
    //==========================================================
    #ifndef TWI_ENABLED
    #define TWI_ENABLED 1
    #endif
    // <o> TWI_DEFAULT_CONFIG_FREQUENCY  - Frequency
     
    // <26738688=> 100k 
    // <67108864=> 250k 
    // <104857600=> 400k 
    
    #ifndef TWI_DEFAULT_CONFIG_FREQUENCY
    #define TWI_DEFAULT_CONFIG_FREQUENCY 26738688
    #endif
    
    // <q> TWI_DEFAULT_CONFIG_CLR_BUS_INIT  - Enables bus clearing procedure during init
     
    
    #ifndef TWI_DEFAULT_CONFIG_CLR_BUS_INIT
    #define TWI_DEFAULT_CONFIG_CLR_BUS_INIT 0
    #endif
    
    // <q> TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT  - Enables bus holding after uninit
     
    
    #ifndef TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT
    #define TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0
    #endif
    
    // <o> TWI_DEFAULT_CONFIG_IRQ_PRIORITY  - Interrupt priority
     
    
    // <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
    // <0=> 0 (highest) 
    // <1=> 1 
    // <2=> 2 
    // <3=> 3 
    // <4=> 4 
    // <5=> 5 
    // <6=> 6 
    // <7=> 7 
    
    #ifndef TWI_DEFAULT_CONFIG_IRQ_PRIORITY
    #define TWI_DEFAULT_CONFIG_IRQ_PRIORITY 7
    #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
    
    // </e>
    
    // <e> TWI1_ENABLED - Enable TWI1 instance
    //==========================================================
    #ifndef TWI1_ENABLED
    #define TWI1_ENABLED 0
    #endif
    // <q> TWI1_USE_EASY_DMA  - Use EasyDMA (if present)
     
    
    #ifndef TWI1_USE_EASY_DMA
    #define TWI1_USE_EASY_DMA 0
    #endif
    
    // </e>
    
    // <q> TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED  - Enables nRF52 anomaly 109 workaround for TWIM.
     
    
    // <i> The workaround uses interrupts to wake up the CPU by catching
    // <i> the start event of zero-frequency transmission, clear the 
    // <i> peripheral, set desired frequency, start the peripheral, and
    // <i> the proper transmission. See more in the Errata document or
    // <i> Anomaly 109 Addendum located at https://infocenter.nordicsemi.com/
    
    #ifndef TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED
    #define TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 0
    #endif
    
    // </e>
    
    // </e>

    More information about the translation layer can be found in the migration document here: https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/migration.html?cp=4_0_0_1_9_4_0#migration_drivers_nrfx

     

     

  • Hi,

    If you want to use nrfx functions you need to remove all TWI (legacy) defines from sdk_config file. It is not enough to set TWI_ENABLE to 0.

Reply Children
Related