cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
715 Views
Registered: ‎09-28-2018

AXI IIC Multi-Byte Read

I'm using the AXI IIC IP block to communicate with a number of sensors and while I'm having some success, I seem completely unable to get a multi-byte reads to work. I'm primarily targeting "Dynamic Controller Logic Flow" but I've experienced the same issues following the other workflows. 

Here's what works. I have a device at address 0x10 with, among other things, a 1-byte device ID at register 0xFD and a 2-byte sensor reading at register 0x08.

So let's say I want to read the Device ID using Dynamic Controller Logic Flow:

# devmem 0x00005120 32 0x0000000F         -- Set of the RX_FIFO_PIRQ to max 
# devmem 0xa0005100 32 0x00000003         -- Control Register: Set Enable = 1, TX FIFO Reset = 1
# devmem 0xa0005100 32 0x00000001         -- Control Register: Set Enable = 1, Clear TX FIFO Reset
# devmem 0xa0005104                       -- Check the Status Register
0x000000C0                                -- Cool. Both RX/TX FIFOs empty
# devmem 0xa0005108 32 0x00000120         -- Write to TX FIFO: Stop = 0, Start = 1, Device Addr = 0x10, R/W = 0 (write)
# devmem 0xa0005108 32 0x000000FD         -- Write to TX FIFO: Register Address 0xFD
# devmem 0xa0005108 32 0x00000121         -- Write to TX FIFO: Stop = 0, Start = 1, Device Addr = 0x10, R/W = 1 (read)
# devmem 0xa0005104                       -- Check status register
0x00000088                                -- Cool. RX FIFO NOT Empty, Tx FIFO Empty, SRW  = 1 (master reading from slave)
# devmem 0xa000510C                       -- Read the RX FIFO
0x0000005B                                -- Nailed it! 0x5B is the correct device ID  

                             
If I repeat the exact process above but target register 0x08, I can get the MSBs of the 2-byte sensor reading I'm looking for. So what about getting both bytes back? I tried to follow the directions in the documentation which explains that after sending the device address with the repeated start, you should send the number of bytes to the TX_FIFO with the STOP bit set. When I do this though, I still only get the MSBs back in the RX FIFO and the TX FIFO shows not empty, almost as if it doesn't know what to do with the "number of bytes" word I wrote down:

# devmem 0x00005120 32 0x0000000F         -- Set of the RX_FIFO_PIRQ to max 
# devmem 0xa0005100 32 0x00000003         -- Control Register: Set Enable = 1, TX FIFO Reset = 1
# devmem 0xa0005100 32 0x00000001         -- Control Register: Set Enable = 1, Clear tX FIFO Reset
# devmem 0xa0005104                       -- Check the Status Register
0x000000C0                                -- Cool. Both RX/TX FIFOs empty
# devmem 0xa0005108 32 0x00000120         -- Write to TX FIFO: Stop = 0, Start = 1, Device Addr = 0x10, R/W = 0 (write)
# devmem 0xa0005108 32 0x00000008         -- Write to TX FIFO: Register Address 0x08
# devmem 0xa0005108 32 0x00000121         -- Write to TX FIFO: Stop = 0, Start = 1, Device Addr = 0x10, R/W = 1 (read)
# devmem 0xa0005108 32 0x00000202         -- Write to TX FIFO: Stop = 1, Start = 0, Number of Bytes = 2
# devmem 0xa0005104                       -- Check status register 0x00000008                                -- Cool. RX FIFO NOT Empty, AND Tx FIFO NOT Empty?, SRW  = 1 (master reading from slave) # devmem 0xa000510C                       -- Read the RX FIFO 0x00000061                                -- Ok. 0x61 are the MSBs of my 2-byte reading
# devmem 0xa000510C                       -- Read the RX FIFO
0x00000061                                -- Welp... there are the MSBs again... no LSBs
# devmem 0xa0005104                       -- Check status register
0x00000048 -- RX FIFO empty... TX FIFO NOT Empty ???

 

So what am I missing/doing wrong here? As mentioned, I tried the other programming flows (which manipulate the CR for starts/stop) with similar results. I've also gotten the same behavior on other sensors/registers. Any help here would be greatly appreciated. 

 

Tags (3)
0 Kudos
8 Replies
Highlighted
Moderator
Moderator
625 Views
Registered: ‎04-09-2019

Hi,

Can you please tell me what do you mean by device ID already you have device address. As per the flow Device address, internal address along with the number of bytes to read is fine why are you using device ID? Please point me the data sheet to clarify what are you doing wrong.

Regards,

Venu

0 Kudos
Highlighted
577 Views
Registered: ‎09-28-2018

Venui. 

The 1-byte "Device ID" in my example is just a 1-byte register on the device that I'm reading as a test. Basically it's just a known value that I'm reading to demonstrate that I'm successfully communicating with the part when only getting a single byte. So in the example, I should always be able to read 0x5B from device register 0xFD. Which I am.

Again, this is just a demonstration to prove that the interface isn't completely borked. My issue comes in when I try to read a different register that is a 2-byte value found at register 0x08. I try to setup the core for the 2-byte read in the second example, but I only get one byte back and the core seems to be confused by my request.

I'm looking for someone to review how I am requesting the 2-byte read in the second example.

0 Kudos
Highlighted
Visitor
Visitor
354 Views
Registered: ‎12-19-2018

Hi,

I also encounter the same I2C multi-byte read issue. 

I follow the Pseudo Code for Dynamic IIC Accesses in pg090, but IIC controller only read one byte from slave rather than four.  Is it the bug of AXI IIC IP? Or pseudo code need to do some modification?

Thanks.

David Chou

 

0 Kudos
Highlighted
Moderator
Moderator
349 Views
Registered: ‎04-09-2019

Hi 

Please enable the controller after filling the transmit data into TXFIFO instead of enabling the controller and filling the data. 

Regards,

Venu

0 Kudos
Highlighted
Visitor
Visitor
313 Views
Registered: ‎08-26-2020

Hi

I am also having same issue...

I am writing to eprom for 10 address location , but while i am trying to read as multibyte then it is giving same value..(which mean it read only one time and that value remain in Rx FIFO , so when i am trying to read 10 location i m getting same value)

i also tried your approach of enabling the controller after writing the FIFO..

still no success..

Hoping to get reply and solution here.

 

0 Kudos
Highlighted
Moderator
Moderator
303 Views
Registered: ‎04-09-2019

Can you please add your source code.

Regards,

Venu

0 Kudos
Highlighted
Visitor
Visitor
282 Views
Registered: ‎08-26-2020

Hi,

 
 
I have tried to read before writing to x"209" to tx fifo as a stop bit and number of data read.
everytime it give the same result ...all address gives the same value while reading.
 
Thanks
0 Kudos
Highlighted
Moderator
Moderator
252 Views
Registered: ‎04-09-2019

Hi,

Looks you are not using xilinx example source code, kindly test read functionality by modifying the attached code with your slave device details.

I am attaching the simple code here to test from you end.

Regards,

Venu

0 Kudos