rp2040 and PCF8574 #1227
-
Hi, I didn't get the I2C connection between pico board and pcf8574 from waveshare to work on GPIO0 nd GPIO1.
sending test data is done by
Any idea what`s wrong?
Dietmar |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments
-
@dietmarczekay Where are I2C_SDA and I2C_SCL defined? What libraries are included? |
Beta Was this translation helpful? Give feedback.
-
both are defined separately
and the following libraries are included:
the jumper on the pcf8574 board are set to adress 0x21 |
Beta Was this translation helpful? Give feedback.
-
Maybe it's this? "Each GPIO can have one function selected at a time. Likewise, each peripheral input (e.g. UART0 RX) should only be selected on one GPIO at a time. " That suggests you should free up the I2C peripheral first, by setting the function of the default I2C pins as something else, e.g. GPIO_FUNC_PIO0 or GPIO_FUNC_PIO1 - I'm not clear which of those two is the normal GPIO pin setting. https://raspberrypi.github.io/pico-sdk-doxygen/group__hardware__gpio.html |
Beta Was this translation helpful? Give feedback.
-
UART ist disabled via platformio settings. And i thought the Pin function ist set by the gpio_set_function command 😐 |
Beta Was this translation helpful? Give feedback.
-
You could try:
before:
I don't know if this will work, but the idea is to detach pins 4 and 5 from the internal I2C peripheral, before you try to assign the new pins and initialise it. The document linked to in my previous post suggests that it's possible to have two pins assigned to the same peripheral function, but that you shouldn't do that because it will cause problems. Setting GPIO_FUNC_NULL will disable those two pins, which might not be what you want, but seems safe to try. |
Beta Was this translation helpful? Give feedback.
-
I will give it a try tomorrow. Thanks |
Beta Was this translation helpful? Give feedback.
-
No improvement. Do you know any working example? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
@dietmarczekay I have no experience of platformIO, or any real desire to learn to use it. Is trying it from just the Arduino IDE an option? That's all I use with the Pico, with Earle's core added via the Boards manager. |
Beta Was this translation helpful? Give feedback.
-
In Arduino the code works as expected:
|
Beta Was this translation helpful? Give feedback.
-
I found a solution for my problem. It seems the problem was, that I didn't used all 8 ports. So 4 of them are floating around. As a result the PCF8574 didn't showed the correct answer to sending a zero (light up all 4 LEDs). |
Beta Was this translation helpful? Give feedback.
I found a solution for my problem. It seems the problem was, that I didn't used all 8 ports. So 4 of them are floating around. As a result the PCF8574 didn't showed the correct answer to sending a zero (light up all 4 LEDs).
Pulling up the unused ports to 3V3 solved this, so now sending a zero, all LEDs are lighted up.