RobTillaart / PCF8575

Arduino library for PCF8575 - 16 channel I2C IO expander
MIT License
73 stars 10 forks source link

frequent reads from a pcf8575 #21

Closed sgrizzi closed 2 years ago

sgrizzi commented 2 years ago

I need to poll several inputs to check if certain events take place and I use bursts of read() requests. A read() from the PCF8575 takes ca. 300uS, but the main loop of the esp32 may run faster than this, which could result in a read requests being issued to the 8575 before the previous one has been completed. Are requests queued? or is there any "busy" flag which can be used? or I just need to adequately delay the read requests?

RobTillaart commented 2 years ago

There is no provision for multithreading

RobTillaart commented 2 years ago

Are requests queued?

no

or is there any "busy" flag which can be used?

no

or I just need to adequately delay the read requests?

You better use semaphores to control the access to the I2C bus. Note: this problem is larger than the PCF8575 library, other devices on the same bus will/could be affected too.

sgrizzi commented 2 years ago

OK, very clear, and it is definitely not related only to the pcf8575... Thanks!