I2C random read not returning correct data value

Skip to first unread message

Hugh Frater

Sep 19, 2018, 7:03:13 AM9/19/18
to BeagleBoard
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:

Screenshot from 2018-09-19 11:45:32.png

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:

Screenshot from 2018-09-19 11:46:11.png

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...

Reply all
Reply to author
0 new messages