Hello,
I have failed to get the I2C working on the nrf54l15dk, i have now connected it to a oscilloscope with pull ups.
i have confirmered the pull ups work, but as i have my oscilloscope never triggers it means the signal is never going low.
is there something i am missing?
#ifndef MAIN_H #define MAIN_H #include <zephyr/kernel.h> #include <zephyr/drivers/gpio.h> #include <zephyr/drivers/i2c.h> #include "../firmware/bhi360.fw.h" /* 1000 msec = 1 sec */ #define SLEEP_TIME_MS 1000 /* The devicetree node identifiers for chip select and another GPIO. */ #define CS_NODE DT_NODELABEL(cs_pin) #define SDO_NODE DT_NODELABEL(sdo_pin) /* The devicetree node identifier for the "led0" alias. */ #define LED_NODE DT_ALIAS(led1) /* The devicetree node identifier for the BHI360 sensor. */ #define BHI360_NODE DT_NODELABEL(bhi360)
#include <stdio.h> /* GPIO configuration */ static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED_NODE, gpios); static const struct gpio_dt_spec cs_pin = GPIO_DT_SPEC_GET(CS_NODE, gpios); static const struct gpio_dt_spec sdo_pin = GPIO_DT_SPEC_GET(SDO_NODE, gpios); /* I2C device */ static const struct i2c_dt_spec bhi360 = I2C_DT_SPEC_GET(BHI360_NODE); int main(void) { configure(); while (1) { blink_led(); int ret; uint8_t config[2] = {0x03,0x8C}; ret = i2c_write_dt(&bhi360, config, sizeof(config)); if(ret != 0){ printk("Failed to write to I2C device address %x at reg. %x \n\r", bhi360.addr,config[0]); } k_msleep(SLEEP_TIME_MS); } return 0; }
&pinctrl { i2c1_default: i2c1_default { group1 { psels = <NRF_PSEL(TWIM_SDA, 2, 1)>, <NRF_PSEL(TWIM_SCL, 1, 3)>; }; }; i2c1_sleep: i2c1_sleep { group1 { psels = <NRF_PSEL(TWIM_SDA, 2, 1)>, <NRF_PSEL(TWIM_SCL, 1, 3)>; low-power-enable; }; }; }; / { aliases { i2c1 = &i2c21; // Creating an alias for easy referencing if needed }; }; /* Enable I2C and configure pins */ &i2c21 { compatible = "nordic,nrf-twim"; status = "okay"; clock-frequency = <I2C_BITRATE_STANDARD>; // 100kHz standard clock frequency pinctrl-0 = <&i2c1_default>; pinctrl-1 = <&i2c1_sleep>; pinctrl-names = "default","sleep"; bhi360: bhi360@28 { compatible = "bosch,bhi360"; reg = <0x28>; label = "BHI360"; status = "okay"; }; }; / { gpio_signals { compatible = "gpio-keys"; cs_pin: chip_select_signal { gpios = <&gpio0 5 GPIO_ACTIVE_HIGH>; label = "Chip Select Signal"; }; sdo_pin: sdo_signal { gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>; label = "SDO Signal"; }; }; };
CONFIG_I2C=y CONFIG_GPIO=y CONFIG_I2C_NRFX_TWIM=y
king regards Luca