I am trying to scan for sensors on an I2C bus using the nrf54L15 and Zephyr RTOS. I modified the i2c example from here: https://github.com/iFransL/i2c-scanner/tree/main
I ran the code sample on the nRF54L15 DK. Everything works perfectly and I am able to detect devices on the bus. I wanted to run the same code sample on my custom board. But I couldn't get it to work.
- On the nRF54L15DK, I was using i2c port i2c21 and the pins 11 and 12 of GPIO port 1. Everything works perfectly
- On my custom board, I am using i2c port i2c21 and the pins 0 and 1 of GPIO port 2. I am not able to detect any devices on the I2C bus.
Since my custom board has a connector to connect external sensors, I tried connecting the I2C bus on the custom board to the nRF54L15 DK. The DK can detect sensors on my custom board.
It definitely has to do with configuration of the I2C bus on my custom board. How can I troubleshoot this problem? Any help is appreciated.
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#define I2C_NODE DT_NODELABEL(my-i2c)
int main(void)
{
const struct device *dev;
dev = DEVICE_DT_GET(DT_NODELABEL(i2c21));
if (!device_is_ready(dev)) {
return -1;
}
uint8_t error = 0u;
uint8_t dst;
uint8_t i2c_dev_cnt = 0;
struct i2c_msg msgs[1];
msgs[0].buf = &dst;
msgs[0].len = 1U;
msgs[0].flags = I2C_MSG_WRITE | I2C_MSG_STOP;
while(1){
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
&i2c21 {
status = "okay";
pinctrl-0 = <&i2c21_default>;
pinctrl-1 = <&i2c21_sleep>;
pinctrl-names = "default", "sleep";
};
&pinctrl {
/omit-if-no-ref/
i2c21_default: i2c21_default {
group1 {
psels = (TWIM_SCL, 2, 1),
(TWIM_SDA, 2, 0);
};
};
/omit-if-no-ref/
i2c21_sleep: i2c21_sleep {
group1 {
psels = (TWIM_SCL, 2, 1),
(TWIM_SDA, 2, 0);
low-power-enable;
};