cancel
Showing results for 
Search instead for 
Did you mean: 

Frustrating I2C Problem: STM32L-Discovery

jbh0001
Associate II
Posted on November 20, 2012 at 18:54

 

 

The original post was too long to process during our migration. Please click on the attachment to read the original post.
10 REPLIES 10
frankmeyer9
Associate II
Posted on November 21, 2012 at 08:31

When I attach the STM, I cannot get the line to go low. I've tried changing a number of different values during the I2C_Init() phase, but none seem to change the fact that the STM32 is holding the line high.

 

That is not the way I2C works. By definition, SDA and SCL need to be open-drain, to have multiple devices/masters on the bus. This pins are only high if no other device pulls it low.

If one device pulls the bus low, the others cannot pull it up.

In effect, this means your bus master probably feigns death.

2) When the EEPROM is sitting on the bus by itself, the voltage of both SCL and SDA are 5.04V.

 

Not a good idea. The STM will only work with 3.3V bus voltage.

Either reduce the supply (and bus) voltage of the other devices, or use level shifters.

There is a chance that the other problems disappear then.

jbh0001
Associate II
Posted on November 22, 2012 at 00:13

Thank you very much for your response. It has given me some new thoughts. I did not realize that the stm i2c bus works on 3.3v not 5v. 

When I attach the STM, I cannot get the line to go low.

 

That is not the way I2C works. By definition, SDA and SCL need to be open-drain, to have multiple devices/masters on the bus. This pins are only high if no other device pulls it low.

 

If one device pulls the bus low, the others cannot pull it up.

 

In effect, this means your bus master probably feigns death.

 

What I meant is I can't get other devices to pull the line low when the STM is attached. I can communicate with my EEPROM using the Aardvark, but only when the STM is not attached to the bus. Once I attach the STM, when the Aardvark tries to send a message, nothing happens. Right now I would be happy just to have the STM sitting on the i2c bus doing nothing, passive, while other devices talk to each other.

frankmeyer9
Associate II
Posted on November 22, 2012 at 09:38

Once I attach the STM, when the Aardvark tries to send a message, nothing happens. Right now I would be happy just to have the STM sitting on the i2c bus doing nothing, passive, while other devices talk to each other.

 

This means, the STM is assumed to be an i2c slave.

You will need to configure it in this way. Most code examples around here assume the STM as master.

jbh0001
Associate II
Posted on November 23, 2012 at 19:11

Okay. Away from the lab right now visiting family, but when I get back I will give that a try as well.

I did switch the bus supply to 3.3v, but still no luck trying to get the STM to send a write signal (this was with only the STM and the EEPROM attached to the bus). The code continues to hang while checking to see if the line is free.

Thank you for your responses. Hope you are having a good holiday.

From: fm

Posted: Thursday, November 22, 2012 9:38 AM

Subject: Frustrating I2C Problem: STM32L-Discovery

Once I attach the STM, when the Aardvark tries to send a message,nothing happens. Right now I would be happy just to have the STM sittingon the i2c bus doing nothing, passive, while other devices talk to eachother.

 

This means, the STM is assumed to be an i2c slave.

You will need to configure it in this way. Most code examples around here assume the STM as master.

jbh0001
Associate II
Posted on November 25, 2012 at 03:49

Good news! I got the STM32L to talk! I was using the wrong pins!

I was able to make it communicate using a bus voltage of both 5v and 3.3v. Other minor problems involved trying to use the pins for two different Alternate Functions at the same time.

If anyone is interested in the source then please send me a PM!

Thanks for your help fm

Posted on November 25, 2012 at 14:17

If anyone is interested in the source then please send me a PM!

Not sure the forum has such a feature, suggest you provide a public email address, or external link, if you which others to contact you.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jbh0001
Associate II
Posted on November 27, 2012 at 16:46

Looks like you are correct. If anyone is interested in discussing I2C on this particular board, drop a line to aubiesatsoftware@gmail.com.

Here's something perplexing: I can get the I2C bus to work on pins PB10 and PB11 (I2C2), but the same code won't work on pins PB6 and PB7(I2C2). Any thoughts? 

EDIT: 

Page 37 contains a description of the Main & Alternate functions of PB10 and PB11

Page 39 contains a description of the Main & Alternate functions of PB6 and PB7

I think this has something to do with PB6 and PB7 being connected to LED3 and LED4.

When I plug those pins into the I2C bus (remember it's pulled up) those LEDs light up.

http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00277537.pdf

frankmeyer9
Associate II
Posted on November 27, 2012 at 17:15

Here's something perplexing: I can get the I2C bus to work on pins PB10 and PB11 (I2C2), but the same code won't work on pins PB6 and PB7(I2C2). Any thoughts? 

 

...

 

I think this has something to do with PB6 and PB7 being connected to LED3 and LED4.

 

When I plug those pins into the I2C bus (remember it's pulled up) those LEDs light up.

 

Most likely this is the case.

I wouldn't waste too much time trying to find out which one of the bus participants is not willing to drive this LED. Easiest way is probably to remove the LED, as the discovery board is rather cheap.

mdonati9131
Associate II
Posted on March 20, 2013 at 12:49

Hello hoodjay,

I'm trying to use the i2c on the same device.

Could you please send me the code?

Are you using interrupts in your code or while's?

Thanks,

Michael