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

The sdk_config.h file is not being parsed by the compiler

I cannot get the scope of the sdk_config.h file to encompass all modules. Process

  • Start with example project using the file system as per the install.
  • After compiling and running on the DK, copy the example files over to a new folder for inclusion into revision control.
  • Edit the project file to make sure the relative paths have been properly modified to reflect the new project folder
  • Make sure the project still compiles and runs.
  • Make an edit that includes a new module, in this case the TWIM
  • dutifully edit the sdk_config.h file to enable the TWIM module
  • Compiler error in main at this line: static const nrfx_twim_t twi0 = NRFX_TWIM_INSTANCE(TWI_INSTANCE_ID);
  • When expanding the macro the compiler cannot find a definition for "NRFX_TWIM0_INST_IDX" because it is not enumerated in nrfx_twim.h because NRFX_TWIM0_ENABLED is not defined
  • Go back and check the nrf_config.h file and it is indeed enabled.
  • Find out that disabling other modules in the nrf_config.h file doesn't have an effect, ergo the nrf_config.h file is not being used.
  • To make sure the pathways are not pointing to another version, disable (rename) all other nrf_config.h files in the file system - no effect.
  • Explicitly define NRFX_TWIM0_ENABLED in nrfx_twim.h and everything compiles fine.
  • make a test header file with just that line and include it in main - no effect.
  • include that same test header file in nrfx_twim.h file, everything compiles fine
  • remove the test include and include the sdk_config.h file in the nrfx_twim.h file, compile fails again

What on earth is going on? I've searched up and down the project settings thinking that the config file is disabled somehow, but nothing. 

Parents
  • Hi,

    It sounds like the problem may be caused by the "apply_old_config" header located in the /<SDK>/integration directory. This file is responsible for making sure NRFX_ configurations correspond to their respective legacy NRF_ configurations. I.e.,  override the NRFX_ setting whenever the legacy setting is different. 

    TWI legacy settings

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

    And the corresponding TWI NRFX settings

     

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

    Is the TWI_ENABLED symbol defined in your sdk_config file, and is it set to '1'? In any case, If you are not using the legacy APIs for the TWI driver, I would suggest that you instead remove the legacy symbols from your configuration file and only use the NRFX_TWIM_ configurations. That will prevent the settings from being overridden. 

    Best regards,

    Vidar

Reply
  • Hi,

    It sounds like the problem may be caused by the "apply_old_config" header located in the /<SDK>/integration directory. This file is responsible for making sure NRFX_ configurations correspond to their respective legacy NRF_ configurations. I.e.,  override the NRFX_ setting whenever the legacy setting is different. 

    TWI legacy settings

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

    And the corresponding TWI NRFX settings

     

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

    Is the TWI_ENABLED symbol defined in your sdk_config file, and is it set to '1'? In any case, If you are not using the legacy APIs for the TWI driver, I would suggest that you instead remove the legacy symbols from your configuration file and only use the NRFX_TWIM_ configurations. That will prevent the settings from being overridden. 

    Best regards,

    Vidar

Children
Related