51 MCU-IIC

Publisher:Heavenly999Latest update time:2015-04-10 Source: eechina Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
IIC (Inter-Intergrated Circuit) bus is a two-wire serial bus developed by PHILIPS. It is used to connect microcontrollers and their peripheral devices. IIC only needs two wires, SDA (data line) and SCL (clock). IIC supports multiple masters. Of course, there can only be one master at any time, while SPI is one master and multiple slaves. All the controlled circuits of IIC are connected in parallel on this bus, and each module and circuit has a unique address. SPI uses CS for chip selection, and as many SPIs as there are will occupy as many ports. The IIC bus has three signals during data transmission, which are: start signal, end signal and response signal.  

Hardware structure diagram of IIC bus:  


   
IIC supports multiple masters and master-slave working modes, usually master-slave working mode. In the master-slave working mode, there is only one master device (single-chip microcomputer) in the system, and the other devices are peripheral slave devices with IIC bus. In the master-slave working mode, the master device starts the data transmission (sends a start signal), generates a clock signal, and sends a stop signal. Start signal: SCL is high, SDA changes from high to low, and data transmission starts. End signal: SCL is high, SDA changes from low to high, and data transmission ends. Response signal: After receiving 8-bit data, the IC receiving data sends a specific low-level pulse to the IC sending data, indicating that the data has been received. After the CPU sends a signal to the controlled unit, it waits for the controlled unit to send a response signal. After receiving the response signal, the CPU makes a judgment on whether to continue to transmit data based on the actual situation. If no response signal is received, it is judged that the controlled unit has a fault.    

Among these signals, the start signal is necessary, and the end signal and response signal can be omitted.  

When the IIC bus transmits data, the data on the data line must remain stable during the high-level period of the clock signal. Only when the clock signal is low, the high or low level state of the data line is allowed to change. The      


  
IIC bus protocol stipulates that after each byte of data is transmitted, there must be a response signal to determine whether the data transmission has been received by the other party. The response signal is generated by the receiving device. During the high-level period of the SCL signal, the receiving device pulls SDA to a low level, indicating that the data transmission is correct and a response is generated.  


   
IIC bus timing diagram:  



Many microcontrollers do not have IIC bus interface, such as 51 microcontroller.  

Microcontroller simulates IIC bus communication:  

Start code: void start(){
    SDA = 1;
    delay();
    SCL = 1;
    delay();
    SDA = 0;
    delay();
}

  Stop code:

  
    void stop(){
    SDA = 0;
    delay();
    SCL = 1;
    delay();
    SDA = 1;
    delay();
}
Reference address:51 MCU-IIC

Previous article:Design of three-phase thyristor trigger circuit for microcomputer controlled welding machine
Next article:51 MCU-IO port

Recommended ReadingLatest update time:2024-11-16 16:56

MSP430 and PCF8576 driver (you can learn from the usage of IIC)
  #i nclude "msp430x14x.h" #define uint unsigned int #define uchar unsigned char #define Num_of_Results 8 unsigned int results ; uchar PCF8576=0x70;//Device address //Memory data definition uchar ByteCnt; //I2C data byte counter uchar SlvAdr; //Slave address uchar SubAdr; //Slav
[Microcontroller]
Cortex-M3 (NXP LPC1788) IIC controller
        The I2C communication protocol was introduced in the previous article. Now let's analyze the I2C controller of LPC1788. To use the I2C module, you need to configure the corresponding registers, such as power, clock, pins, etc. Take I2C0 as an example, configure P0.27 and P0.28 pins as SDA and SCL functions resp
[Microcontroller]
Cortex-M3 (NXP LPC1788) IIC controller
Freescale 16-bit MCU (XII) - IIC module test
1. Introduction to IIC module         Currently, many single-chip microcomputers on the market already have hardware IIC bus control units. When such single-chip microcomputers are working, the IIC bus status is monitored by hardware, and no user intervention is required, making operation convenient.         The IIC
[Microcontroller]
Freescale 16-bit MCU (XII) - IIC module test
PIC microcontroller software simulation IIC read and write routines
;I2C bus program  ;this is eeprom read & write programm  ;the special store ram unit  w equ 0  f0 equ 0  rt CC     equ 1  pc    equ 2  f2    equ 2  f3    equ 3  f4    equ 4  ra    equ 5  rb    equ 6  rc    equ 7  pclath    equ 0ah  i NTC on    equ 0bh  pir1    equ 0ch  tmr1l    equ 0eh  tmr1h    equ 0fh  t1con    equ 
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号