IIC (I2C) SDA Line always low??

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IIC (I2C) SDA Line always low??

4,312 Views
JonHart
Contributor I
Hi,
 
I am having some difficutly talking to an IIC device. As soon as I set the BEN (IIC enable bit) the IBB (bus busy bit) gets set and never clears.  Since this is the first check done in any transfer, I'm rather stuck.
 
code:
 
void IIC_Start(unsigned int adr) {
 cpuIBFD = 0x1b; 
 
  //****HELP - STUCK IN THIS WHILE LOOP!****
 while(cpuIBSR & 0x20);     // wait for IBB flag to clear

 // NEVER GET TO HERE

 cpuIBCR |= 0x30;           // set TX and master mode 
 cpuIBDR = 0x18|(adr << 1);     // 0x18 = %00011[00/01]0
  
 while((cpuIBSR & 0x02) == 0);  // wait for IBIF flag to be set  

 
 cpuIBSR |= 0x02;               // clear IBIF flag
}

I have checked the SDA line and it is always low (even on a processor reset).  Is this normal?  I am wondering if there is a hardware fault.  I have 10K pull ups on SDA and SCL.  The bus length is a few cm and there are two devices on the bus.

 
Regards
 
Jon
Labels (1)
0 Kudos
3 Replies

1,071 Views
JonHart
Contributor I
Thanks for the input.  Was a hardware fault.  One of the i2c digipots (ad5242) was faulty on my board.
0 Kudos

1,071 Views
mjbcswitzerland
Specialist V

Hi Jon

How have you declared "cpuIBSR"?
It should be declared as "volatile" to ensure that the compiler is not optimising to read the value once and then running in the while loop with this value and never seeing that the bit has changed.

Otherwise maybe there is really a hardware problem...(?)

Regards

Mark Butcher
www.mjbc.ch

0 Kudos

1,071 Views
imajeff
Contributor III
Sorry but I had to replace the MCU when that happened to me. I don't know if there are other things that might be wrong, though.
0 Kudos