cancel
Showing results for 
Search instead for 
Did you mean: 

Have I to use an I2C pin to write into EEPROM ?

STM32L0Fan
Associate II

I ask this question because I am already using all the i2c pins for my lcd screen and I need to write in EEPROM and it seems that I need to configure a I2C to use the hal function to write ...

11 REPLIES 11
Mike_ST
ST Employee

Hello,

If you have an I2C EEPROM in your design, you'll have to configure an I2C instance to communicate with it.

STM32L0Fan
Associate II

I saw that it was maybe possible to use a SPI pin, do you know if it is possible to write/read eeprom with SPI ?

(thank you for your first answer btw)

Mike_ST
ST Employee

1) SPI is not I2C.

2) There is solution to simulate I2C using 2 GPIO. google "STM32 software I2C", hopefully you'll find something.

LMI2
Lead

Besides, an I2C bus can be connected to more than one devices/slaves. I2C devices have addresses, so that it is possible to know what device you are currently using.

As @LMI2​ said, I2C is a bus - the whole point of a bus is that multiple devices can share it. That's why it has addresses.

You don't need a separate I2C for each peripheral:

0693W00000BcwrDQAR.pnghttps://en.wikipedia.org/wiki/I%C2%B2C

https://learn.sparkfun.com/tutorials/i2c/all

https://learn.adafruit.com/i2c-addresses

https://www.i2c-bus.org/

https://www.nxp.com/docs/en/user-guide/UM10204.pdf

@STM32L0Fan​ : "do you know if it is possible to write/read eeprom with SPI ?"

That depends on the EEPROM:

  • if it's an I2C EEPROM, then you can only read it with I2C;
  • if it's an SPI EEPROM, then you can only read it with SPI;
  • some EEPROMs can work with both SPI and I2C

You will have to study the documentation for your EEPROM to find which applies ...

State the SPECIFIC parts we're talking about here, the STM32 and EEPROM at the very least

Both SPI and I2C use multiple PINS

I2C parts are addressable, usually the manufacturers chose address ranges that don't clash, and often have address jumpers to select between multiple addresses.

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

Ok thank you for your answer, the answer to my issue is that with the hal function : HAL_FLASHEx_DATAEEPROM_Program() you can do what I wanted to do.

That would suggest you're using an STM32L0 part, with an Internal EEPROM, not an external one using I2C or SPI

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