cancel
Showing results for 
Search instead for 
Did you mean: 

STM with Microchip AT24C512C EEPROM in keil microvision I2C communication

kunj_2308
Associate II

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.

4 REPLIES 4

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 Venmo
Up vote any posts that you find helpful, it shows what's working..
kunj_2308
Associate II

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

 

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

 

If you feel a post has answered your question, please click "Accept as Solution".

I used the SPL for many years, I didn't port those projects, but did pivot into the HAL when the boards were respun / updated, as I'd rather not ski uphill.

STM32F10x_StdPeriph_Lib_V3.6.0\Project\STM32F10x_StdPeriph_Examples\I2C\EEPROM

STM32F10x_StdPeriph_Lib_V3.6.0\Utilities\STM32_EVAL\STM32L152_EVAL\stm32l152_eval_i2c_ee.c

https://www.st.com/en/embedded-software/stsw-stm32054.html

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