I2C communication application [I2C of STM32]
![](https://en.depfields.com/wp-content/uploads/2020/06/cyberspace-2784907_640.jpg)
This application program reads and writes to the I2C specification type EEPROM of STM32 MCU. Details of the peripherals are explained in Serial Communication I2C.
![](https://en.depfields.com/wp-content/uploads/2020/06/i2c-eeprom_NUCLEO_en.jpg)
![](https://en.depfields.com/wp-content/uploads/2020/05/instructor.jpg)
Here PB10 and PB11 are used for I2C2. Data read from memory is transferred to the monitor using USART3 for display.
![](https://en.depfields.com/wp-content/uploads/2020/05/instructor.jpg)
The chip address of the I2C EEPROM is A0 because A0, A1, and A2 are set to 0 V as shown in the above figure. Please refer to the I2C EEPROM 24LCxx datasheet for details.
![](https://en.depfields.com/wp-content/uploads/2020/05/instructor.jpg)
Three data (data1, data2, data3) are written to and read from the I2C EEPROM.
![](https://en.depfields.com/wp-content/uploads/2020/05/instructor.jpg)
Immediately after program startup, the data stored in EEPROM is displayed.
Program Description
![](https://en.depfields.com/wp-content/uploads/2020/05/instructor.jpg)
When one of the three character string commands "1@", "2@", or "3@" is entered by a PC, the data corresponding to that command is written into the EEPROM, and the stored data is read and displayed every 1000 ms cycle.
![](https://en.depfields.com/wp-content/uploads/2020/05/instructor.jpg)
Data is rewritten each time a command is entered.
![](https://en.depfields.com/wp-content/uploads/2020/05/instructor.jpg)
It is operated from a PC via serial UART communication to monitor the status of read/write (send/receive functions).