IIC (I2C) SDA Line always low??

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

IIC (I2C) SDA Line always low??

4,659件の閲覧回数
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
ラベル(1)
0 件の賞賛
返信
3 返答(返信)

1,418件の閲覧回数
JonHart
Contributor I
Thanks for the input.  Was a hardware fault.  One of the i2c digipots (ad5242) was faulty on my board.
0 件の賞賛
返信

1,418件の閲覧回数
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 件の賞賛
返信

1,418件の閲覧回数
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 件の賞賛
返信