I’m driving a device on I2C2 from code within the PRU… 5 byte reads are working properly (address, command, response, byte 1, byte 2) and I can see on my scope that the correct value is being read from the device (a microchip MCP4641 digital pot) but it takes 2 calls of my code before the correct value is available in the I2C2_DATA register. The first call returns the previously read/written value…
Screenshots below show this best I think:
Here is the I2C write capture:
Here is the I2C read from the above terminal log (note I’m using the PRU Uart looped back into userspace as a debug output):
But note that on the terminal log above the 2nd byte that was pumped out the PRU Uart was 0x71 yet the scope shows 0x6F was read across the bus.
A 2nd call of the read_wiper function causes the correct value to be output:
We are a small team of experienced embedded devs with many years MCU experience across many architectures, we have a lot of I2C experience, and this one has us stumped… Help…