Serial EEPROM (I2C based) writes/reads only first time..

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 Hi,

   

I am using the CY8CKIT-049-42XX prototype board for my experiments. I am trying to interface  a I2C based EEPROM 24LC256 to the board. The SDA pin of the EEPROM is connected to P0[5] pin of the board (also configured as SDA) and the SCL pin of EEPROM to P0[4] pin on the board. The bus lines (SDA and SCL) are pulled up via 3.3K resistors.

   

I use the following code in the main.c file to read a byte in the EEPROM

   

void ReadExtEEPROM(uint32 SlaveAddress,uint32 MemAddress){

   

    uint8 ret=0;

   

    I2C_I2CMasterClearStatus();

   

    I2C_I2CMasterSendStart(SlaveAddress,0);

   

    I2C_I2CMasterWriteByte(MemAddress>>8);

   

    I2C_I2CMasterWriteByte(MemAddress);    

   

    I2C_I2CMasterSendRestart(SlaveAddress,1);

   

    ret=I2C_I2CMasterReadByte(0);

   

    return (ret);

   

}

   

 

   

void WriteExtEEPROM(uint32 SlaveAddress,uint32 MemAddress,uint8 MemData){

   

    I2C_I2CMasterSendStart(SlaveAddress,0);

   

    I2C_I2CMasterWriteByte(MemAddress>>8);

   

    I2C_I2CMasterWriteByte(MemAddress);

   

    I2C_I2CMasterWriteByte(MemData);

   

    I2C_I2CMasterSendStop();

   

}

   

 

   

The problem is I can read the byte correctly for the first time (after power up) after which the reads always return 0. The address to which I read has be written previously (using the above WriteExtEEPROM) with a known value. So I know what value is expected..

   

Please help...

   

Thanks

   

a

0 Likes
5 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

A couple of working projects here -

   

 

   

    

   

          

   

http://www.cypress.com/?app=forum&id=4749&rID=107688

   

http://www.element14.com/community/thread/25086/l/psoc-4-pioneer-kit-community-project037-psoc-with-...

   

 

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Hi,

   

Thanks for the tips. I got it working there was a problem with the addressing...

   

 

   

thanks

   

a

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Glad to have assisted.

   

 

   

Regards, Dana.

0 Likes
moro_1580446
Level 5
Level 5
100 replies posted 50 replies posted 25 replies posted

Hi every body.I want to running at24c512 with psoc5lp.so can you realse your project file here?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Would be much better to start a new thread instead of using a two year old one.

   

 

   

Bob

0 Likes