i2c New Driver

User avatar
arunbm123
Posts: 98
Joined: Fri Feb 23, 2018 5:36 am

i2c New Driver

Postby arunbm123 » Tue Nov 19, 2024 7:27 am

hi,

I am using new Drivers in v5.3 i2c Master and Slave Drivers.
Both Master and Slave are Esp32

I send from Master for Example, 1 byte 0x55

At the Slave I get 2 times 0x55 0x55
or Even Some times I get four Times 0x55 0x55 0x55 0x55

Any Idea Why is it so ?

Thanks

User avatar
ESPBoards
Posts: 10
Joined: Wed Jan 17, 2024 9:05 pm

Re: i2c New Driver

Postby ESPBoards » Sat Nov 23, 2024 5:06 pm

Could be do to several things...

1. Glitches on I2C bus: Check pull-up resistors and try reducing bus speed (e.g., to 100kHz).
2. Master retransmissions: Ensure the master sends data only once and handles acknowledgments correctly.
3. Slave buffer issues: Clear the slave buffer after reading data.
4. Repeated slave interrupts: Ensure the slave ISR isn’t triggered multiple times per transmission.

Without the code, cannot tell you more unfortunatelly.
ESPBoards.dev - Everything about ESP32 and ESP8266 Development Boards - https://www.espboards.dev

eriksl
Posts: 199
Joined: Thu Dec 14, 2023 3:23 pm
Location: Netherlands

Re: i2c New Driver

Postby eriksl » Wed Apr 23, 2025 7:55 am

This is to be expected. The master, not the slave determines when a transaction is finished (by sending a NAK). As long as the master doesn't send a NAK, the client has to supply "some" data, it cannot flag an exception. In most cases, when the client has no more data to send, it just keeps repeating the last byte.

If you want the client to be able to inform the master how many bytes can be read, the client must the inform the master explicitly, e.g. send the amount of bytes available as the first byte or make a register/command available to the master to fetch that information separately.

Who is online

Users browsing this forum: Applebot, Bytespider and 4 guests