Skip to main content
Associate II
December 5, 2024
Question

STM with Microchip AT24C512C EEPROM in keil microvision I2C communication

  • December 5, 2024
  • 2 replies
  • 2836 views

Currently, I am using Keil Microvision 5 for programming STM32. Now, I want the example code of I2C to communicate between EEPROM and STM. I am using the STM32F103C8 controller and AT24C512C EEPROM. I searched about that, but I only found the example codes of STM32CUBEIDE and codes based on the HAL library. So if anyone have that code or example please send me. here I have attached the datasheet of STM controller and EEPROM.

2 replies

Tesla DeLorean
Guru
December 5, 2024

So should we infer that you're using SPL rather than HAL?

Some reason to continue to do that, when ST abandoned it 6 or 7 years ago?

Might be some examples in the SPL, I don't recollect, but I2C was always very awkward. 

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
kunj_2308Author
Associate II
December 5, 2024

Yeah, I preferred SPL over HAL because our organization uses SPL, and all our programs were previously in SPL. Can you provide me with the code, if you have it?

 

and these are the reasons to use the SPL over HAL 

  1. Lower Resource Overhead
  2. Direct and Fine-Grained Hardware Control
  3. Simpler and Clearer APIs
  4. Stability and Reliability
  5. Better Performance in Time-Critical Applications
  6. Transparency and Debugging
  7. No Dependency on STM32Cube

 

Senior III
December 5, 2024

If you are good at I2C calls in SPL, it is easy to implement for i2C EEPROM. You can write to any location by writing first address byte which is composed of page+location. After sending the address, do a i2C restart and send the data. In EEPROM data is always stored as bytes. In your program convert other types to array of bytes, write it into locations. While reading, do the reverse. The datasheet of this EEPROM gives you the logic for the i2c write for bytes, page write examples.

 

Techn_0-1733408101434.png