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
chen
Associate II
Posted on December 18, 2013 at 17:34

Hi

Can I check my understanding :

EV5 = transmitted Start bit in master transmit mode

EV6 = Address and W/R bit sent + ACK

?

''I'm getting '' Bus error & Arbitration loss '' error.''

It is likely that the I2C bus has SDA or SCL pulled low.

You need to put an oscilloscope or logic analyser on the bus and look at what is happening.

You are not always in total control of the I2C bus. The SDA and SCL are open collector outputs - meaning that it is possible for some other device to pull the lines low.

ss2
Associate II
Posted on December 19, 2013 at 08:25

Thanks for reply sung.chen_chung

    Actually I'm using stmf103 controller & 24c04 EEPROM. Here the only master is controller & only one slave is EEPROM.so how bus line can be pulled low ?? &  I'm  getting '' Bus error & Arbitration loss '' error. I tried but i could not able to notice anything on oscilloscope, still it appears for a fraction of second. Is their any other way to clear this error ?? Please..help me

chen
Associate II
Posted on December 19, 2013 at 11:11

Hi

It does not matter that you only have a single master and single slave device.

Any device can pull either SDL or SCK low.

Both SDL and SCK must be high to signify the bus is idle.

If either line is low (when you probe with your scope) then no I2C transmittion can occur.

From you description - you are not successfully sending the start bit or possibly not sending the device address +R/W bit.

Do you understand the I2C protocol?

Are you just trying to write code to talk the the EEPROM?

ss2
Associate II
Posted on December 19, 2013 at 12:04

Yes, you are right Start bit is not initiating, even if its initiated also I'm not getting response for address transmission. I'm getting Bus error or Arbitration lost error.. As per you the Bus line is pulled low right... what can i do, to proceed for next step ? what are the points should i note down to have a synchronous communication ? See the attachment....

Thank you.. waiting

________________

Attachments :

I2c_Code.txt : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hztv&d=%2Fa%2F0X0000000bQx%2F9fPkDBMVEna9g4eJtKd.Zx5b2Tah29tsnunqcQcu6Dc&asPdf=false
chen
Associate II
Posted on December 19, 2013 at 12:08

Is the bus idle before you start transmission?

Most good I2C drivers check for an idle bus.

ss2
Associate II
Posted on December 19, 2013 at 12:24

  Ya it's idle only.... After power ON I'm initiating start condition... Should i give any Delay ??

Thank you...

chen
Associate II
Posted on December 19, 2013 at 12:33

Before any I2C transmission, the software should check the bus is ok/idle.

Have you checked the datasheet for the eeprom?

How long does it take before it is ready?

ss2
Associate II
Posted on December 20, 2013 at 09:51

hi , i really thank you for the support that i am getting from u, i have read the eeprom datasheet its taking less than 3 milisec, i do have attached the code could you plz find the mistake that i am doing ,so that it will be very helpful for me and will learn from my mistake ,plz do the need ful, will attach the code plz find the attachment

regards

selva

________________

Attachments :

I2c_Code.txt : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hztq&d=%2Fa%2F0X0000000bQv%2FFJTFicXrbnbmK3J3Nb2PRyCclGfQbb5b4Y_e7tKQk0s&asPdf=false
chen
Associate II
Posted on December 20, 2013 at 13:37

Hi Selva

That is OK. I understand that you are getting frustrated.

What I am trying to do is to get you to understand that sometimes, the problem is not in the code. You are dealing with electronics here and they have their quirks.

I am trying to get you to understand the system (the STM32 Discovery + the I2C EEPROM that you have attached).

''i have read the eeprom datasheet its taking less than 3 milisec''

3ms is a very long time for embedded processor!

Well actually <3ms is a useless figure!

''After power ON I'm initiating start condition... Should i give any Delay ??''

Yes - a BIG delay if the EEPROM take 3ms