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

Linking error with TWI in SAADC example code

Hi Nordic team,

I am trying to enable I2C driver in SAADC example which is located in examples\peripheral\saadc\pca10040\blank\arm5_no_packs

As you can see I am using Keil V5

This example is working perfectly. The issue is when I am trying to use TWI in this.

nrf_drv_twi.c, nrfx_twi.c and nrfx_twim.c are added to project.

sdk_config.h didn't have the option to enable TWI, so I added following to 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

// <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 6
#endif
// </e>

Following is being included in the code

#include "nrf_drv_twi.h"
#include "nrf_twi.h"
#include "nrf_twim.h"

I have read through a lot of topics, everywhere above two solutions are suggested but I am still getting the following errors

linking...
.\_build\nrf52832_xxaa.axf: Error: L6218E: Undefined symbol nrfx_twi_init (referred from nrf_drv_twi.o).
.\_build\nrf52832_xxaa.axf: Error: L6218E: Undefined symbol idle_state_handle (referred from i2c_control.o).
.\_build\nrf52832_xxaa.axf: Error: L6218E: Undefined symbol nrfx_twi_disable (referred from i2c_control.o).
.\_build\nrf52832_xxaa.axf: Error: L6218E: Undefined symbol nrfx_twi_enable (referred from i2c_control.o).
.\_build\nrf52832_xxaa.axf: Error: L6218E: Undefined symbol nrfx_twi_rx (referred from i2c_control.o).
.\_build\nrf52832_xxaa.axf: Error: L6218E: Undefined symbol nrfx_twi_tx (referred from i2c_control.o).
.\_build\nrf52832_xxaa.axf: Error: L6218E: Undefined symbol nrfx_twi_uninit (referred from i2c_control.o).
Not enough information to list image symbols.
Not enough information to list load addresses in the image map.
Finished: 2 information, 0 warning and 7 error messages.
".\_build\nrf52832_xxaa.axf" - 7 Error(s), 3 Warning(s).
Target not created.
Build Time Elapsed:  00:00:51

Can someone please let me know where I am going wrong?

Parents
  • Hi, 

    According to the error messages, you miss the nrfx_twi - TWI peripheral driver. Please add the following setting in the 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
    
    // <q> NRFX_TWI1_ENABLED - Enable TWI1 instance
    
    #ifndef NRFX_TWI1_ENABLED
    #define NRFX_TWI1_ENABLED 0
    #endif
    
    // <o> NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency
    
    // <26738688=> 100k 
    // <67108864=> 250k 
    // <104857600=> 400k
    
    #ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY
    #define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688
    #endif
    
    // <q> NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit
    
    #ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT
    #define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0
    #endif
    
    // <o> NRFX_TWI_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_TWI_DEFAULT_CONFIG_IRQ_PRIORITY
    #define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6
    #endif
    
    // <e> NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module.
    //==========================================================
    #ifndef NRFX_TWI_CONFIG_LOG_ENABLED
    #define NRFX_TWI_CONFIG_LOG_ENABLED 0
    #endif
    // <o> NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level
    
    // <0=> Off 
    // <1=> Error 
    // <2=> Warning 
    // <3=> Info 
    // <4=> Debug
    
    #ifndef NRFX_TWI_CONFIG_LOG_LEVEL
    #define NRFX_TWI_CONFIG_LOG_LEVEL 3
    #endif
    
    // <o> NRFX_TWI_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_TWI_CONFIG_INFO_COLOR
    #define NRFX_TWI_CONFIG_INFO_COLOR 0
    #endif
    
    // <o> NRFX_TWI_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_TWI_CONFIG_DEBUG_COLOR
    #define NRFX_TWI_CONFIG_DEBUG_COLOR 0
    #endif
    
    // </e>

    Because the i2c_control.c only uses TWI driver instead of TWIM driver, please disable it. 

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

    -Amanda H.

Reply
  • Hi, 

    According to the error messages, you miss the nrfx_twi - TWI peripheral driver. Please add the following setting in the 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
    
    // <q> NRFX_TWI1_ENABLED - Enable TWI1 instance
    
    #ifndef NRFX_TWI1_ENABLED
    #define NRFX_TWI1_ENABLED 0
    #endif
    
    // <o> NRFX_TWI_DEFAULT_CONFIG_FREQUENCY - Frequency
    
    // <26738688=> 100k 
    // <67108864=> 250k 
    // <104857600=> 400k
    
    #ifndef NRFX_TWI_DEFAULT_CONFIG_FREQUENCY
    #define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688
    #endif
    
    // <q> NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT - Enables bus holding after uninit
    
    #ifndef NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT
    #define NRFX_TWI_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0
    #endif
    
    // <o> NRFX_TWI_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_TWI_DEFAULT_CONFIG_IRQ_PRIORITY
    #define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6
    #endif
    
    // <e> NRFX_TWI_CONFIG_LOG_ENABLED - Enables logging in the module.
    //==========================================================
    #ifndef NRFX_TWI_CONFIG_LOG_ENABLED
    #define NRFX_TWI_CONFIG_LOG_ENABLED 0
    #endif
    // <o> NRFX_TWI_CONFIG_LOG_LEVEL - Default Severity level
    
    // <0=> Off 
    // <1=> Error 
    // <2=> Warning 
    // <3=> Info 
    // <4=> Debug
    
    #ifndef NRFX_TWI_CONFIG_LOG_LEVEL
    #define NRFX_TWI_CONFIG_LOG_LEVEL 3
    #endif
    
    // <o> NRFX_TWI_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_TWI_CONFIG_INFO_COLOR
    #define NRFX_TWI_CONFIG_INFO_COLOR 0
    #endif
    
    // <o> NRFX_TWI_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_TWI_CONFIG_DEBUG_COLOR
    #define NRFX_TWI_CONFIG_DEBUG_COLOR 0
    #endif
    
    // </e>

    Because the i2c_control.c only uses TWI driver instead of TWIM driver, please disable it. 

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

    -Amanda H.

Children
No Data
Related