Skip to main content
Graduate
December 5, 2024
Question

STM with Microchip AT24C512C EEPROM in keil microvision I2C communication

  • December 5, 2024
  • 2 replies
  • 2835 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.

    This topic has been closed for replies.

    2 replies

    Graduate II
    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. 

    kunj_2308Author
    Graduate
    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

     

    Graduate II
    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