Wrong clock speed in raspberry pi pico leads to wrong reading address #74074
Unanswered
seyednasermoravej
asked this question in
Q&A
Replies: 1 comment 1 reply
-
|
This isn't a bug, the datasheet clearly shows 3 address lines on this chip: https://www.ti.com/lit/ds/symlink/pcf8574.pdf page 12 So 0x27 is the correct address when A0, A1 and A2 are high |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
I wanted to use PCF8574 IO expander module for the Raspberry Pi Pico (AKA: rpi_pico board). The default address for PCF8574 is 0x20. But I can't communicate with this module. I tried Arduino UNO and it found the module at 0x20 address. The same as I expected. After trying to scan the I2C bus, I found out that the Pico can find the module but at 0x27 address instead of 0x20. I checked the difference between the Pi Pico and UNO signals, the only difference is the frequency of their signals. The requested speed is 100KHz in both. While UNO achieves the exact frequency, the Pi Pico can't.
Please also mention any information which could help others to understand
the problem you're facing:
I'm expecting to find the PCF8574 module on 0x20 address, while it found at 0x27 address in the Pi Pico.
To Reproduce
Steps to reproduce the behavior:
Create an overlay file next to your project.
Add these lines into overlay file:
`
&i2c1_default {
group1 {
pinmux = <I2C1_SDA_P14>, <I2C1_SCL_P15>;
};
};
&i2c1{
status = "okay";
pinctrl-0 = <&i2c1_default>;
label = "I2C_1";
clock-frequency = <I2C_BITRATE_STANDARD>;
expander: pcf857x@27 {
compatible = "nxp,pcf857x";
status = "okay";
reg = <0x27>;
gpio-controller;
#gpio-cells = <2>;
ngpios = <8>;
};
lcdout: pcf857x@21 {
compatible = "nxp,pcf857x";
status = "okay";
reg = <0x21>;
gpio-controller;
#gpio-cells = <2>;
ngpios = <8>;
};
lcdin: pcf857x@22{
compatible = "nxp,pcf857x";
reg = <0x22>;
gpio-controller;
#gpio-cells = <2>;
ngpios = <8>;
};
};
`
Create a main.c file and add these lines into the main function:
const struct device *i2c_dev;
uint8_t addr;
int ret;
i2c_dev = device_get_binding("I2C_1");
if (!i2c_dev) {
printf("Error: I2C device not found\n");
return;
}
printf("Scanning I2C bus...\n");
while (1)
{
for (addr = 1; addr < 128; addr++) {
struct i2c_msg msg;
uint8_t dummy_data = 0;
}
k_msleep(1000);
}
You'll see the output like this:
uart:~$ Scanning I2C bus...
Device found at address 0x27
Device found at address 0x27
Device found at address 0x27
Device found at address 0x27
Expected behavior
I'm expecting to find the device at the address of 0x20, instead of 0x27.
Logs and console output

The requested frequency is 100KHz, the achieved frequency is shown in the picture.
Environment (please complete the following information):
Additional context
I saw the same problem here i2c speed incorrect. So, I'm not sure if it is a software of hardware issue but it wasted me about 1 day at least.
Best regards,
Beta Was this translation helpful? Give feedback.
All reactions