Skip to content

Unclear how to use pico as a I2C slave #192

Closed
@davidedelvento

Description

@davidedelvento

According to https://raspberrypi.github.io/pico-sdk-doxygen/group__hardware__i2c.html the pico can set itself as a slave device. In such a mode, one would guess that something like the following would work:

while(true) {
    if (i2c_get_write_available(i2c1) > 0) {
        i2c_write_raw_blocking(i2c1, data, 1); 
    } else {
        tight_loop_contents();
    }
}

Instead it doesn't. The master (in my case another Pico), who has posted a corresponding i2c_read_blocking() call, does not receive anything and everything hangs. Note that one cannot use i2c_write_blocking() instead of the raw variant, because the master has no address.

According to generic I2C documentation something like this should work... It is curious that there are so many (basically identical) examples of using the Pico as master, and not even one example of how to use it as slave. Proving even a single one, simple working example would really be helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions