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

nRF52832 LIS3DH I2C

Hi, Im using a nRF52DK to read LIS3DH accelerometer readings in putty. Im new to this platform, I tried couple of example programs like blinkey, uart, and button in BLE. Now Im trying to establish I2C connection between DK and LIS3DH. I found some programs and libraries in github, but they are compatible only with nRF51 series. Then I found this approach in nordic devzone When I try to build this program, I get the following errors. For your reference, I'm using visual studio coder. 

c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Karthi\Documents\nRF5_SDK\nRF5SDK1702d674dde\nRF5_SDK_17.0.2_d674dde\project\ble_peri\lisnew\pca10040\blank\armgcc/../../../main.c:111: undefined reference to `nrf_twi_sensor_init'
c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\Karthi\Documents\nRF5_SDK\nRF5SDK1702d674dde\nRF5_SDK_17.0.2_d674dde\project\ble_peri\lisnew\pca10040\blank\armgcc/../../../main.c:114: undefined reference to `lis2dh12_init'
c:/program files (x86)/gnu arm embedded toolchain/9 2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: _build/nrf52832_xxaa/main.c.o: in function `lis2dh12_who_am_i_read':
C:\Users\Karthi\Documents\nRF5_SDK\nRF5SDK1702d674dde\nRF5_SDK_17.0.2_d674dde\project\ble_peri\lisnew\pca10040\blank\armgcc/../../../lis2dh12_internal.h:744: undefined reference to `nrf_twi_sensor_reg_read'
collect2.exe: error: ld returned 1 exit status
make: *** [_build/nrf52832_xxaa.out] Error 1
The terminal process "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command make flash" terminated with exit code: 1.

Let me explain what are the steps I have done.

I used the twi_sensor example and included the lis2dh 12 driver flies in this work space. In the reference able, it is told, both lis2dh and lis3dh have the same spec sheet. So, the code should works with lis3dh sensor. 

From what I understand, the sdk_config has to be configured to use this library. I don't know how to configure and what are the drivers and functions I have to enable to do that. 

Please help me to fix this. Also, If you think any other approach is simple and efficient, please let me know. Im open to suggestions. 

Parents Reply
  • 1. no it does not use nrf_twi_sensor_init() and nrf_twi_sensor_reg_read() .

    2. In the future, this project work might be commercialized, so we decided to go with visual studio.

    what I think my problem might be is, I did not include the header file properly. Initially, I just copied the required library files and pasted in the workspace folder. I think that gave me the undefined reference problems. 

    Initially, I use to have one more error, undefined reference to `nrf_twi_mngr_init' that error disappeared when I created the project from twi_master example folder.

    can anyone help me to include the libraries in visual studio code?

    I included the path in c_cpp_properties.json but the header doesn't seem to be found. I get no such file or directory error.

    correct me if I'm wrong.

Children
Related