Failed to run LIS2DH sample

Hello,

Used environment: 

  • Board: nrf9151dk_nrf9151_ns
  • SDK Toolchain: v3.0.2
  • IDE: Vscode

I'm trying to test the LIS2DH sample using the nrf9151DK and the STEVAL-MKI151V1. The wiring is as follow: 

  • vdd_lis2dh        vdd_dk (configured to 3.3V using Nrf Connect Desktop)
  • vdd_io_lis2dh   vdd_dk 
  • scl_lis2dh         scl_dk (pin 28)
  • sda_lis2dh        sda_dk (pin 29)
  • gnf_lis2dh         gnd_dk

I've used this example as reference:  zephyr/samples/sensor/lis2dh.

I've modifed my prj.conf as follow: 

CONFIG_SENSOR=y
CONFIG_LOG=y
CONFIG_I2C_NRFX=y
CONFIG_LOG_DEFAULT_LEVEL=4
CONFIG_LOG_BACKEND_UART=y
CONFIG_EARLY_CONSOLE=y
CONFIG_I2C_LOG_LEVEL_DBG=y
CONFIG_SENSOR_LOG_LEVEL_DBG=y

I've added an overlay as follow: 

&i2c1 {
    status = "okay";
    clock-frequency = <I2C_BITRATE_STANDARD>;
    pinctrl-0 = <&i2c1_default>;
    pinctrl-1 = <&i2c1_sleep>;
    pinctrl-names = "default", "sleep";
    lis2dh@18 {
        compatible = "st,lis2dh";
        reg = <0x18>;
    };
};

&pinctrl {
    i2c1_default: i2c1_default {
        group1 {
            psels = <NRF_PSEL(TWIM_SCL, 0, 28)>,
                    <NRF_PSEL(TWIM_SDA, 0, 29)>;
            bias-pull-up;
        };
    };

    i2c1_sleep: i2c1_sleep {
        group1 {
            psels = <NRF_PSEL(TWIM_SCL, 0, 28)>,
                    <NRF_PSEL(TWIM_SDA, 0, 29)>;
            low-power-enable;
        };
    };
};

The build/flash are OK but in the UART0 console, I've got this error: 

[00:00:00.287,597] <dbg> os: setup_thread_stack: stack 0x2000e1f8 for thread 0x2000ccb0: obj_size=1024 buf_start=0x2000e1f8 buf_size 1024 stack_ptr=0x2000e5f8
[00:00:00.287,628] <dbg> os: setup_thread_stack: stack 0x2000e0b8 for thread 0x2000cbf8: obj_size=320 buf_start=0x2000e0b8 buf_size 320 stack_ptr=0x2000e1f8
[00:00:00.287,689] <dbg> clock_control: clkstarted_handle: lfclk: Clock started
[00:00:00.287,719] <dbg> os: setup_thread_stack: stack 0x2000d5b8 for thread 0x2000c6e0: obj_size=768 buf_start=0x2000d5b8 buf_size 768 stack_ptr=0x2000d8b8
[00:00:00.290,679] <err> os: ***** BUS FAULT *****
[00:00:00.290,679] <err> os: Precise data bus error
[00:00:00.290,679] <err> os: BFAR Address: 0x0
[00:00:00.290,710] <err> os: r0/a1: 0x0001e46c r1/a2: 0x00000001 r2/a3: 0x01980000
[00:00:00.290,710] <err> os: r3/a4: 0x40009000 r12/ip: 0x00000000 r14/lr: 0x000162e9
[00:00:00.290,740] <err> os: xpsr: 0x21000000
[00:00:00.290,740] <err> os: Faulting instruction address (r15/pc): 0x0001625e
[00:00:00.290,771] <err> os: >>> ZEPHYR FATAL ERROR 25: Unknown error on CPU 0
[00:00:00.290,832] <err> os: Current thread: 0x2000ccb0 (main)
[00:00:00.404,052] <err> os: Halting system

I've tried: 

  • Modifiing the periph to i2c0 or i2c2 -> another issue of build (conflict with uarte0)
  • Changing the pins of SDA and SCL -> same issue

Investigating the addresses using: 
C:\nrf_exercies\lis2dh>addr2line -e build/lis2dh/zephyr/zephyr.elf 0x000162e9

I've got:
C:/ncs/v3.0.2/modules/hal/nordic/nrfx/drivers/src/nrfx_twim.c:341

So It seems like an I2C error misconfiguration error. 

Do you have any idea how can i solve this ?

Thank you in advance.

Parents
  • In general, a nRF91 has are 4 communication units, and you may use each for UART, I2C, or SPI. That's referred by uart0, uart1, uart2, uart3 or i2c0, i2c1, i2c2, i2c3

    The nRF9151-DK maps does units as default to (see nrf9151dk_nrf9151_common.dtsi):

    uart0: logging

    uart1: modem trace

    i2c2: sensors

    spi3: flash

    Also some GPIO are assigned by default (see nrf9151dk_nrf9151_common-pinctlr.dtsi):

    i2c2 has sda P0.30 and scl P0.31

    uart1 has tx P0.29, rx P0.28, rts P0.16, cts P0.17

    it's possible to change that, but the result must not end in conflicts.

    So, let me propose the you just use i2c2 with sda P0.30 and scl P0.31 (and also check the voltage for these GPIOs via the Board Configurator App (nRF for Desktop). That will be a easy way to check the LIS2DH.

    If you then really want to change the defaults, please ensure, that the pins you want to use are really not bound to other devices. Though uart1 is used for modem traces, the tx/rx are already connected to the USB2serial. I'm not sure, if that's a good idea to try to use them for i2c, that may interfere with the USB2serial.

         

Reply
  • In general, a nRF91 has are 4 communication units, and you may use each for UART, I2C, or SPI. That's referred by uart0, uart1, uart2, uart3 or i2c0, i2c1, i2c2, i2c3

    The nRF9151-DK maps does units as default to (see nrf9151dk_nrf9151_common.dtsi):

    uart0: logging

    uart1: modem trace

    i2c2: sensors

    spi3: flash

    Also some GPIO are assigned by default (see nrf9151dk_nrf9151_common-pinctlr.dtsi):

    i2c2 has sda P0.30 and scl P0.31

    uart1 has tx P0.29, rx P0.28, rts P0.16, cts P0.17

    it's possible to change that, but the result must not end in conflicts.

    So, let me propose the you just use i2c2 with sda P0.30 and scl P0.31 (and also check the voltage for these GPIOs via the Board Configurator App (nRF for Desktop). That will be a easy way to check the LIS2DH.

    If you then really want to change the defaults, please ensure, that the pins you want to use are really not bound to other devices. Though uart1 is used for modem traces, the tx/rx are already connected to the USB2serial. I'm not sure, if that's a good idea to try to use them for i2c, that may interfere with the USB2serial.

         

Children
No Data
Related