cancel
Showing results for 
Search instead for 
Did you mean: 

The I2C doesn't work! (STM32f030 and STM32f103)

rozehtiyan
Associate II
Posted on September 02, 2014 at 18:54

Hi ST partisans! (Wink)

I have written two program for my two MCU. STM32F103RET6 and STM32f030. in the circuit, the STM32F030 should send ''Rohalamin'' string over I2C (as Master) . on the other hand, the STM32F103RET6 should recieve the string and if it's correct, the STM32F103RET6 should turn on an LED by the PB0.

Ok, now you know that What's the configurations and I have attached several pictures from circuit:

http://www.imageupload.co.uk/images/2014/09/02/02092014565.jpg

http://www.imageupload.co.uk/images/2014/09/02/02092014568.jpg

http://www.imageupload.co.uk/images/2014/09/02/02092014569.jpg

http://www.imageupload.co.uk/images/2014/09/02/02092014571.jpg

and you can see the configurations for I2C in the debug environment:

http://www.imageupload.co.uk/images/2014/09/02/3RSYQ.jpg

ok, let's to run it on MCU. When I turn on only the STM32F030, I can see just this in the logic analyzer:

http://www.imageupload.co.uk/images/2014/09/02/26Ogx.jpg

and when I connect the STM32F030 to the STM32F103RET6 and turn on the whole of the circuit, the output in the logic analyzer is this:

http://www.imageupload.co.uk/images/2014/09/02/1NT3Gm.jpg

and also when I check the STM32F103RET6 in the debug environment, it doesn't go to the interrupt routin. in my opinion, the problem is in the I2C interrupt of the STM32F103RET (totally I think the problem is STM32F103RET6) . and also I think the hardwares of the circuit is ok.  Really What's the problem? Why doesn't it work correctly?

#i2c #stm32f103 #stm32f030
6 REPLIES 6
Posted on September 02, 2014 at 19:04

Watch carefully the volatility, and lack of NUL termination, of the receive buffer.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
rozehtiyan
Associate II
Posted on September 02, 2014 at 19:31

Hey Clive,

How are you? Thanks for reply.

The I2C is a bit difficult to understand and by the ST MCUs it is more difficult than the I2C protocol itself!

How can I do it (I mean ''watch carefully the volatility, and lack of NUL termination, of the receive buffer'')? is my configurations correct? (especially the program of the STM32F103RET6) I again say, in my program is in the STM32F103RET6.

Posted on September 02, 2014 at 21:15

I'm not getting into I2C on F1 and F0 parts, I've done more work with I2C than anyone should have to in a single life time.

I'd suggest you read your C documentation materials (K&R, or whatever) about the volatile keyword, and it's appropriate use, and then the chapter on Strings and how they work, and why the NUL is important.

Do your boards share a common ground?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
rozehtiyan
Associate II
Posted on September 03, 2014 at 04:34

I'm familiar with ''volatile'' keyword but why I have to use it? the compiler optimization is ''level 0''. then no need to this keyword. and again keep in mind that in the STM32F103's program it doesn't go to the interrupt routine. I cannot understand this sentence:

''Do your boards share a common ground?''

rozehtiyan
Associate II
Posted on September 05, 2014 at 07:25

I'm harassed. I couldn't find the problem still. now, I put the configuration of the I2C in the STM32CubeMX for STM32f030:

http://www.imageupload.co.uk/images/2014/09/05/1iqHGX.jpg

any idea?
rozehtiyan
Associate II
Posted on September 06, 2014 at 18:41

I connected both ground between STM32F030 and STM32f103 and now, when I push the button, I only can see this in the logic analyzer:

http://www.imageupload.co.uk/images/2014/09/06/gifE4.jpg

Not sure but I feel that now it's better than earlier. LoL! and when I just turn on the STM32f030, I see the same result like before(I just see ''0'').