cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
330 Views
Registered: ‎03-03-2017

MicroBlaze I2C stuck in while ((StatusReg & XIIC_SR_BUS_BUSY_MASK) == 0) loop

Hi,

   First the details of my design.   I am working out of Vivado/SDK 2018.1 on a design that includes MicroBlaze, I2C, and HDMI, and the I2C communicates with a TI DP159 chip which is used for HDMI TX Control.   The I2C is AXI IIC (2.0) hardware version according to Vivado and iic_v3_4 SW driver version according to SDK.

   I am dealing with Microblaze hanging once in a while in the proc_mblz\libsrc\iic_v3_4\src\xiic_l.c function "unsigned XIic_Recv(UINTPTR BaseAddress, u8 Address, u8 *BufferPtr, unsigned ByteCount, u8 Option)" in the while loop shown below.

		while ((StatusReg & XIIC_SR_BUS_BUSY_MASK) == 0) {
			StatusReg = XIic_ReadReg(BaseAddress,
						  XIIC_SR_REG_OFFSET);
		}

   So it seems this loop is waiting fo the I2C bus to be busy, but it never gets there.

   My question is if anybody else has experienced something like this with the AXI I2C blocks, and if so what did you possibly do to fix the problem?

   I was thinking I could add in a watchdog timer or something and if so many milliseconds passed while in that loop I would break out.

Thanks.

Tim

0 Kudos
4 Replies
Highlighted
220 Views
Registered: ‎03-03-2017

Re: MicroBlaze I2C stuck in while ((StatusReg & XIIC_SR_BUS_BUSY_MASK) == 0) loop

Looking through the driver files, I see that in SDK 2018.3 iic_v3_5/xiic_I.c the comment below.   I wonder if the problem I am experiencing is what this fix covers.

foo.png

Tim

0 Kudos
Highlighted
199 Views
Registered: ‎03-03-2017

Re: MicroBlaze I2C stuck in while ((StatusReg & XIIC_SR_BUS_BUSY_MASK) == 0) loop

FYI, I did try updating the SW drivers to use the v3_5 files, but I am still getting stuck in this while loop.   I think I may add in a counter in the while loop and see if anything bad happens if I end up jumping out of the loop due to the counter.

Tim

0 Kudos
Highlighted
Explorer
Explorer
146 Views
Registered: ‎06-13-2012

Re: MicroBlaze I2C stuck in while ((StatusReg & XIIC_SR_BUS_BUSY_MASK) == 0) loop

Hi @tim_severance 

Did you check the SDA and SCL levels with an oscilloscope when it happens?

You can try implement a counter in the loop to quit after a while but if the i2c is stuck I'm not sure you will be able to read or write again on the i2c bus.

Regards

 

0 Kudos
Highlighted
123 Views
Registered: ‎03-03-2017

Re: MicroBlaze I2C stuck in while ((StatusReg & XIIC_SR_BUS_BUSY_MASK) == 0) loop

@auricm ,

   I did check while it was stuck and the lines were both quiet and high.  I did implement a counter and jump out if it gets higher than 10 iterations and for now it seems to have fixed my problem.   I have already seen it bail out of the loop a couple of times and things keep working for me.  
   It seems like it might either be a bug in the i2c, or something strange the DP159 chip is doing to the i2c bus like NACKing when it shouldn't or something.  
Tim

0 Kudos