Professional Documents
Culture Documents
1720110395237
1720110395237
1720110395237
STM32 Microcontroller
What is I2C?
I2C (Inter-Integrated Circuit) is a synchronous, multi-master, multi-slave, packet-
switched, single-ended, serial communication bus. Developed by Philips
Semiconductors (now NXP Semiconductors), it allows multiple chips to
communicate with each other using just two wires: SDA (Serial Data Line) and
SCL (Serial Clock Line). I2C is widely used for communication between
microcontrollers and peripherals like sensors, displays, and EEPROMs.
Features of I2C:
➢ Simple 2-Wire Interface: Only two lines, SDA and SCL.
➢ Serial and Synchronous: Data is transferred bit by bit along a single wire
(the SDA line), and is synchronized by the clock (the SCL line).
➢ Multi-Master and Multi-Slave: Multiple master and slave devices can be
connected to the same bus.
➢ Addressing: Each device is addressed by a unique address.
➢ Various Data Transfer Modes:
• Standard-mode: 100kbit/s
• Fast-mode: 400kbit/s
• Fast-mode Plus (Fm+): 1Mbit/s
• High-speed mode: 3.4Mbit/s
• Ultra-Fast-mode: 5Mbit/s (unidirectional)
I2C Terminology:
➢ Master: The device that initiates communication, generates clock signals,
and terminates communication.
➢ Slave: The device that responds to the master's requests.
➢ Transmitter: The device that sends data to the bus.
➢ Receiver: The device that receives data from the bus.
➢ Multi-Master: More than one master can control the bus without
corrupting the message.
➢ Arbitration: Ensures that if multiple masters try to control the bus
simultaneously, only one succeeds, and the message is not corrupted.
Clock Synchronization:
➢ When multiple masters are present, clock synchronization ensures all
devices operate at the same clock speed.
➢ Masters may stretch the clock by holding the SCL line LOW to synchronize
slower devices.
Applications of I2C:
➢ Sensor Data Acquisition: Interfacing sensors like temperature, humidity,
and pressure sensors.
➢ Memory Access: Communicating with EEPROM and other memory
devices.
➢ Display Control: Controlling LCD and OLED displays.
➢ RTC (Real-Time Clock): Synchronizing time with RTC modules.
Conclusion:
The I2C communication protocol remains a cornerstone of modern embedded
systems, providing a balance of simplicity, flexibility, and efficiency. Its ability to
support multiple devices with just two wires makes it a preferred choice for
many applications, while its robust features ensure reliable and error-free
communication.
Understanding and effectively implementing I2C in microcontrollers like the
STM32F401RBT6 can significantly enhance the capability and performance of
embedded systems, making it a crucial skill for developers in the field. Whether
you are designing sensor networks, managing display interfaces, or
synchronizing real-time clocks, I2C offers a versatile and reliable solution to
meet your communication needs.