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

Adding a peripheral to an example using BLE

Hello,

I'm a beginner at developping nrF52832.
My problem is completely similar to this one : devzone.nordicsemi.com/.../add-saadc-peripheral-and-others-to-example-project

My development Environment :
---
SDK : 17.0.2
IDE : Segger embedded Studio V5.50
hardware : Evaluation Board nRF52-DK

What I want to do
---
I am using the example "BLE_app_blinky" as a basis to train on the nRF 52832
I am trying to add a TWI peripheral on this example code.
I use TWI1.
To do so, I tried to copy what was done on the twi_scanner example.

What I have done
---
* add the nrf_drv_twi.c file to the project( add existing file)
* add the nrfx_twim.c file project( add existing file)
* modify the sdk_config.h to allow twi:

* declare my i2C instance :  static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(1);



the change in the sdk_config.h are :
* NRFX_TWI_ENABLED = 1
* NRFX_TWI1_ENABLED = 1

What I have got
---
When I compile, I get the following error:
NRF_DRV_TWI_INSTANCE_1 undeclared ( not in a function)

but NRF_DRV_TWI_INSTANCE_1 should be defined in the nrf_drv_twi.h file if NRFX_TWIM1_ENABLED
With the segger IDE, when I right click to "Go to the definition" to know where NRFX_TWIM1_ENABLED is declared, the IDE takes me to the file "apply_old_config.h"
and not to the file "sdk_config.h"

What is the "apply_old_config.h" file ?
Why is my sdk_config.h not taken into account ?

remarks
---
When I try to add I2C on the ble_app_uart example, I have the same problem!
When I try to add I2C on the SPI example ( no BLE on this example), making the same changes works!

Parents
  • Hello,

    What is the "apply_old_config.h" file ?
    Why is my sdk_config.h not taken into account ?

    Yes, the apply_old_config configuration will overwrite your sdk_config configuration if a legacy *_ENABLED define is left defined in the sdk_config. To avoid this happening you will have to comment out or remove all together the legacy TWI_ENABLED, so that it is not defined, and then only have the NRFX_TWI_ENABLED 1 defined in your project.
    For emphasis; it is not enough to set the TWI_ENABLED to 0, it must be removed completely so that TWI_ENABLED is not defined in your project anymore.

    The apply_old_config file was introduced in order to be backwards compatible when we made the switch from the now legacy nrf_drv drivers to the newer (and current) nrfx_ drivers. This worked as intended when we originally made the switch, but has in the later SDK's been known to cause confusion. I fully agree that this file hierarchy / architecture is sub-optimal, and I apologize for any inconvenience this might have caused you.

    Please try to remove your legacy *_ENABLED definitions from your sdk_config and see if this resolves the issue.

    Best regards,
    Karl

Reply Children
Related