2024-12-05 03:32 AM - last edited on 2024-12-05 07:02 AM by SofLit
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.
2024-12-05 03:51 AM
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.
2024-12-05 04:02 AM - edited 2024-12-05 04:08 AM
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
2024-12-05 06:12 AM - edited 2024-12-05 06:15 AM
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.
2024-12-05 09:00 AM
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