cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in Writing data to EEPROM

ss2
Associate II
Posted on December 18, 2013 at 14:52

Hi

    I'm trying to write data to eeprom using I2C protocol (Polling Method), but while checking event 5 (EV5) as well as event 6 (EV6) I'm getting '' Bus error & Arbitration loss '' error. How can i overcome this... please help me somebody

#i2c #basic-electronics #stm32f103rrbt6 #need-help-interfacing-to-eeprom
20 REPLIES 20
ss2
Associate II
Posted on December 20, 2013 at 14:04

    Have you gone through my code ?? Is their any flaw ??  If not, tell me where should i concentrate ? or what are the things should i consider ??  to be frank i don't know why that error is coming...& what should i do to over come that ? If you have any idea, that will be much helpful for me.... Thanks for your support...

Regards

Selva....

chen
Associate II
Posted on December 20, 2013 at 14:40

I do not see any code here on the posting.

Post it and I will try.

As I said, the problem may not be code.

It could be hat the bus contention is real.

If the bus contention is real - you may not be able to fix it in code.

ss2
Associate II
Posted on December 20, 2013 at 14:47

 Ok... this is my code...

chen
Associate II
Posted on December 20, 2013 at 14:59

Hi

OK, I have had QUICK look (so it is not definitive) :

Not sure if the port pins have I2C output selected on them.

Hopefully, the I2C_init() function does that for you.

The while loops can get stuck forever - you have probably found this.

One thing for you to try is to disconnect the EEPROM  and try the code again.

If the code is OK - you will get a no response error instead.

ss2
Associate II
Posted on December 21, 2013 at 10:34

Hi sung,

              As per your suggestion i removed the eeprom & i tried. I'm not getting any error....

 Thank u sung....
ss2
Associate II
Posted on December 23, 2013 at 07:16

Hi sung.chen_chung,

      I tried using interrupt method, but now I'm getting ''Acknowledgement Failure error'' after initiating the slave address. what should i do to overcome this error ?? why this error is coming ?? any idea ?? help me sombody..

Thank you............

chen
Associate II
Posted on December 23, 2013 at 11:44

Hi

I am beginning to think that you do not understand the I2C protocol.

Do you understand the I2C protocol?

'' I tried using interrupt method, but now I'm getting ''Acknowledgement Failure error'' after initiating the slave address. what should i do to overcome this error ??''

Is this with the EEPROM attached ?

If it is not attached - then you will get a NACK.

ss2
Associate II
Posted on December 23, 2013 at 13:11

Thank you for reply sung,

   I have a doubt.... please don't mind...... As per the datasheet '' the port line should be Open Drain ''  is both SDA & SCL should open drain ? or only SDA ?

   why I'm asking means,  when i configure both SDA & SCL as open drain (with EEPROM or Without EEPROM) connected, I won't get any interrupt & even error also. Only Busy Flag will be High.

   But when i configure both SDA & SCL as Push Pull ( Without EEPROM ), I'll get every time error interrupt (i.e. Ack failure) error.

 

 With EEPROM :-

                              After initiating Start condition I'll get Event interrupt (i.e. EV5 ) & then, when i try to initiate the slave address, I'm getting error interrupt (i.e. Ack failure) error.

 Hope you got the problem... I'm just struck here..... Please help me,  I'm waiting for your response....Thanks

Regards

Selva....

chen
Associate II
Posted on December 23, 2013 at 17:16

Hi

As I thought, you do not understand I2C. Your problem is not just the software.

You must first understand what I2C is and how it works:

Try this first :

http://en.wikipedia.org/wiki/I%C2%B2C

The official specification is here :

http://www.nxp.com/documents/user_manual/UM10204.pdf

(but it is difficult to read unless you are an electronics person)

Basically the bus works by allowing any of the devices pull either SDA or SCK low when they want to. If any of the devices pulls either line low while an I2C transmission is going on - this dissrupts the I2C transmission (the bus collision you were getting).

All I2C transmissions are 9 bits (8 data bits and 1 ACK bit). The ACK bit is left high by the transmit side (master) and the receiver must pull the SDA low to signal an ACK.

I2C Transmissions are signaled with StartBit and StopBit (SDA is changed while SCK is high, while bits are sampled on the transition of SCL going low to high)

You CANNOT drive I2C with push pull - it must be done by open collector.

Most do not use the built in pull up resistors - most use external pull up resistors (2k to 5K will work).

The STM32 has a built in controller which knows how to generate the whole sequence - you just need to set it up for start/stop bits and byte transmissions. However, it can be tricky to get right.

Posted on December 24, 2013 at 11:52

''but it is difficult to read unless you are an electronics person''

If you are doing interfacing work at this level, then you need  at least a sufficient grasp of electronics to be able to understand this kind of specification!

You could start here: 

http://electronicsclub.info/