I2C bug hang up in MC9S08AW32

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

I2C bug hang up in MC9S08AW32

2,477 Views
vishu
Contributor I

Hello,

 

I am using I2C module in MC9S08AW32 to communicate with Freescale MMA7455L accelerometer. I am able to communicate with the accelerometer and read the values from it.

But sometimes, I2C bus hangs up with SCL line high and SDA line low. After this state, I am not able to communicate with the accelerometer. Only when I cutoff the power to accelerometer for few seconds, it starts communicating again. How is that I can reset the I2C bus without resetting the whole board.

 

regards

Vishu

Labels (1)
0 Kudos
4 Replies

600 Views
Summerville
Contributor I

Vishu,

 

Had a similar problem in the past with an IIC master on the QG4/8.  Turned out I was not polling the BUSY flag at the start of a transmission, and sometimes on back-to-back transmissions the new one would start before the signalling of the stop condition of the previous one was done(in software, we clear MST to signal a stop but don't poll until it's done).  This would cause the master to hang on the subsequent transmission.

 

While I'm not sure of the IIC module on the AW32, I suspect its similar.  Before each IIC access, try to poll the BUSY flag until it's clear before sending a start condition.

 

0 Kudos

600 Views
PeterHouse
Contributor I

Vishu,

 

I believe you will find this is a missed ACK of some type.  I had a very similar problem a couple of years ago using a GP32 and ended up bit banging the interface so I could detect the problem and correct it in firmware since the module in the GP32 would just hang with no possible recovery except a power cycle.

 

You can probably catch this on a scope if you trigger on the rising edge of the SDA line and inspect the events after the final trigger up until the data stops.

 

Good Luck,

 

Peter House

0 Kudos

600 Views
vishu
Contributor I

Hi Peter,

 

Thanks for your response.

One more thing I would like to know is, even if I correct my firmware to not to miss the ACK, there might be situations in the field where the I2C bus may hang up.

What I read in many forums is that if we send 9 clock pulses followed by a stop signal on the I2C bus, it will unhang the bus.

Since I am using the AW32 I2C module, I cannot use the pins directly to send 9 clocks.

Is there any other way to unhang the bus?

 

Thanks and Regards

Vishu

0 Kudos

600 Views
PeterHouse
Contributor I

Vishnu,

 

I could not get it to work on the GP32 and had to resort to replacing the module with my own code so I could clear the bus.  It is not very difficult and does not take a lot of CPU time to run.

 

I did spend a lot of time sending scope shots and such to Freescale only to have them blame the issue on the i2c chip or my code.  Funny, when I replaced their module it worked and is still working flawlessly!  I use a lot of Freescale CPUs and this module is the only one which has ever given me this much trouble.

 

Peter

0 Kudos