Hello Devs.
I am porting my whole project from the SDK16 to NCS 1.4.1 on my original project I use I2c and other drivers which works pretty well, but I am able to make them work in Zephyr so I went to the documentation, but it is not clear at all for me.
I tried using the NCS using Segger Embedded Studio and using VisualGDB on Visual Studio, with no luck
on both codes, I used hello_word example and Include the Twi, driver, and instances on Project->Configure nRF Connect SDK Project enabling TWI driver, Enable TWI0 Instance and I2C Driver nRF TWI nrfx driver
nrf52dk_nrf52832.dts including to aliases i2c0 = &i2c0
prj.conf
CONFIG_I2C=y
CONFIG_NRFX_TWI=y
CONFIG_NRFX_TWI0=y
CONFIG_NRFX_TWI1=y
code:
#include <zephyr.h> #include <sys/printk.h> #include <string.h> #include <stdio.h> #include <sys/util.h> #include <device.h> #include <drivers/i2c.h> #define twi DT_LABEL(DT_ALIAS(i2c0)) void main(void){ const struct device *dev = device_get_binding(twi);; if (dev == NULL) { printk("I2C: Device driver not found\n"); } else{ printk("I2C: Device driver found!!!\n"); i2c_configure(dev, I2C_SPEED_SET(I2C_SPEED_STANDARD)); uint8_t data=1; i2c_reg_read_byte(dev, 0x5F, 0x0F, &data); //who am I printk("I2C: I am:%u", data); } }
I got on RTT terminal:
I2C: I am:1*** Booting Zephyr OS build v2.4.0-ncs2 ***
I2C: Device driver found!!!
<err> i2c_nrfx_twi: Error on I2C line occurred for message (error when trying to read I2C)
I2C: I am:1
Using VisualGDB on VisualStudio same result. but I got an error code 195952641
following this post https://devzone.nordicsemi.com/f/nordic-q-a/62585/i2c_nrfx_twim-error-195952641 wheres indicates the address is incorrect which is not my case because I was using it address on the same hardware on my original project where it works.
Can someone point to a possible solution?