0

I would like to read multiple bytes from an I2C device but only one byte at a time. For example, to read 10 bytes from an I2C real time clock I would issue a single read command (send device code write, register address, device code read), and then read back one byte per, say, 100msec in order to read in the 10 bytes over a second. When working with bare metal I could accomplish this with a state machine clocked every 100msec by a timer interrupt and send an ACK when I'm ready to get the next byte, and in doing so I've spread the read rather than wait for the full 10 bytes.

To further this question, is there any way to send one byte at a time, so that in the above example instead of sending a complete read command I send the device code with the rw bit set, then send the address, then send the device code with rw cleared?

Has anyone done this with a Pi? In C?

I am currently using the bcm2835.c library. PIGPIO seems like it might be more flexible for something like this - does that sound right?

TIA.

  • It is not clear if you mean to signal a start/stop condition between each byte transferred. – joan May 28 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.