cancel
Showing results for 
Search instead for 
Did you mean: 

I2C - Unknown event interrupt

krk2
Associate II
Posted on October 21, 2010 at 18:53

I2C - Unknown event interrupt

9 REPLIES 9
krk2
Associate II
Posted on May 17, 2011 at 14:12

In the meantime i solved the unknown event problem. Seems to have something to do with the debugger connection. Without debugger no unknown events anymore but the sporadic bus failure is still there.

I now measured the bus and found some strange spikes on the SDA line after each 9th bit. I attached an image of the spike. I tested the communication on two different boards with different I2C slaves. But the spikes are always there.

I also replaced my I2C code with the AN2824 code example but the result is still the same. Any suggestions ?

0690X00000602i4QAA.jpg0690X00000602iEQAQ.jpg
Singh.Harjit
Senior II
Posted on May 17, 2011 at 14:12

Not sure if you are seeing what I ran into but the symptoms seem similar - when I was generating a restart condition on the bus, I would get the interrupt but the status register showed no source - this was 100% reproducable.

It turned out that if I added a small delay, the start flag propagated into the status register and everything was fine.

I tried changing the ratio of the I2C clock and main processor clock and found that this affected how long it took for the start flag to propagate.

Here is the specific code I use to get around this:

case I2C_ADDRRPT:                                                             

        // the interrupt fires before the I2C status register is updated with the

        // status bit which hangs up this state.                              

                                                                              

        // wait for I2C block to propagate start bit to I2C status register   

        for (ulTemp = 0; ulTemp < 20; ulTemp++)                               

        {                                                                     

                vDelayUS(1);                                                  

                if (I2C1->SR1 & I2C_SR1_SB)                                   

                        break;                                                

        }         

I then write the slave address to the data register which clears start bit in the status register.

greg_t
Associate II
Posted on May 17, 2011 at 14:12

I have the exact problem, my solution is that whenever this erorr occures I do the same I2C operation again.

krk2
Associate II
Posted on May 17, 2011 at 14:12

Do you have also these spikes on the SDA line ? How do you trigger on the failure ? Or do you repeat the I2C command whenver it fails previously ?

greg_t
Associate II
Posted on May 17, 2011 at 14:12

Yes, sometimes the SDA line spikes ... and the I2C registers an event that not supposed to happen and I2C driver gets stuck waiting for the real event. 

I timeout the event if the timeout reached I return FAIL ... and from the main loop if I2C operation Failed it repeats the I2C command again ... 

krk2
Associate II
Posted on May 17, 2011 at 14:12

Ok nice to hear I am not alone :) The strange thing is that the Spike is on

every

9th bit.

Singh.Harjit
Senior II
Posted on May 17, 2011 at 14:12

I think the spike the bus master releasing the SDA line so that the slave can drive it to acknowledge the transfer.

Posted on May 17, 2011 at 14:12

I think the spike the bus master releasing the SDA line so that the slave can drive it to acknowledge the transfer.

Grin. Basically exposing the propagation delay in the bus, and the latency of the slave device. They are probably also ramming the port (0 states) with the 50 MHz driver, instead of the 2 or 5 MHz ones that might be more appropriate.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nanayakkaraan
Associate II
Posted on May 17, 2011 at 14:12

Hello,

I will be lad to know whether you have dealt with I2C event through 2c_Ev interrupts.

Thank you.