Hi,
I am currently looking at some I2C code for a display and wonder if a delay() between Wire.beginTransmission() and Wire.endTransmission() makes any sense. Looking at the docs it looks like bytes are sent out after the Wire.endTransmission() command is executed. Or do I misunderstand something?
I am currently looking at some I2C code for a display and wonder if a delay() between Wire.beginTransmission() and Wire.endTransmission() makes any sense.
No, it simply shows that the author of the code doesn't know how the Arduino I2C subsystem works.
I am actually trying to port the code to STM32CubeIDE and stumbled upon this. I also looked around and watched some Arduino videos on Youtube but nobody actually explained that detail. I think in one of the most watched videos even the author said that his transfers did not complete sometimes but probably forgot to call endTransmission().
@Koepel: a DUE board (main uc is an 32-bit ARM Sam3x) will not behave properly to the Arduino Wire library for multiple reasons.
There is no glitch filtering (unlike most if not any AVR uc), no slope control, is multi-Master compliant (may be an issue) and last but not least (extract from page 715 of Sam3x datasheet): When a single data byte read is performed, the START and STOP bits must be set at the same time, i.e. send a STOP before reading the data byte. When a multiple data byte read is performed, the STOP bit must be set after the next-to-last data received, i.e. before the last data byte to be read.