cancel
Showing results for 
Search instead for 
Did you mean: 

How can I reset a AT24C02A EEPROM chip (I2C) from a STM32F103XB?

Jim Seymour
Senior

I've inherited some source code for a custom board that reads EEPROM data from an Atmel AT24C02A chip. The code is based on the older STM32F103xx firmware library (not the newer STM32Cube code).

Most of the time, everything works fine. However, it occasionally gets a timeout when talking to this chip at powerup. When this happens, it does not seem to recover until a power cycle is done.

According to the AT24C02A data sheet, there is a process to reset the chip by clocking up to 9 cycles and creating a start condition one of those clocks.

Specifically:

MEMORY RESET: After an interruption in protocol, power loss or system reset, any two-wire part can be reset by following these steps:
1. Clock up to 9 cycles
2. Look for SDA high in each cycle while SCL is high
3. Create a start condition as SDA is high.

Can anyone help me get some code running to implement this? I'm at a loss as to how to proceed.

Here is the part of my code that is timing out:

   Timeout = 0xFFFF;
   I2C_GenerateSTART(I2C2, ENABLE);
   while ((I2C2->SR1&0x0001) != 0x0001 && Timeout != 0)
      Timeout--;

This is the first part of a read operation - and when it times out, all subsequent loops also time out.

Thanks.

2 REPLIES 2

You can also drive the pins as GPIO.

Set High states in ODR, flip to GPIO OD mode, read back levels via IDR

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Jim Seymour
Senior

Thanks for the reply. I've since learned that the problem I was chasing was caused by a power supply taking longer than I expected to drop to zero volts after power off. If I cycle power a different way (or wait a few seconds), then my EEPROM behaves properly all the time.

While my original question remains unanswered, I no longer need it answered - so all is good...