I2C communication timing problem of 89 and 12 microcontrollers

Publisher:dadigtLatest update time:2018-12-13 Source: eefocusKeywords:timing Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

I accidentally discovered this problem while using ADC today and would like to share it with all my friends.


I2CDelay of 89:


#define I2CDelay() {_nop_();_nop_();_nop_();_nop_();}


I2CDelay of 12:


void Delay_us(unsigned char us)

{

    do {

        _nop_();

        _nop_();

        _nop_();

        _nop_();

        _nop_();

        _nop_();

        _nop_();

        _nop_();

    } while (--us);

}


I2CDelay(5);


I2C communication is divided into low-speed mode 100kbit/s, fast mode 400kbit/s and high-speed mode 3.4Mbit/s. Because all I2C devices support low speed, but not necessarily the other two speeds, so as a general I2C program, we choose 100k rate to implement, that is to say, the timing generated by the actual program must be less than or equal to the timing parameters of 100k, which obviously requires that the high and low levels of SCL should not be shorter than 5us, so we insert the I2CDelay() bus delay function in the timing function (it is actually 4 NOP instructions, defined at the beginning of the file with define), plus at least one cycle occupied by the statement itself to change the SCL value, to achieve this speed limit.


The 89 routine uses a 11.0592M crystal oscillator. 


12/11059200 is definitely larger than the 1us machine cycle of the 12M crystal oscillator, so the delay of 89 is greater than 4, plus the statement execution time is definitely greater than 5us

Keywords:timing Reference address:I2C communication timing problem of 89 and 12 microcontrollers

Previous article:How to solve the problem of inaccurate timing of 12 single-chip microcomputers
Next article:Summary of Microcontroller Knowledge

Recommended ReadingLatest update time:2024-11-16 15:36

Simulation and Program of Stepper Motor Controlled by STC89C52RC MCU
This single chip microcomputer is STC89C52RC, this program is applied to step motor--28BYJ, a small stepper motor, with a power supply voltage of DC5V. It can be directly connected to the single chip microcomputer and driven by the UL2003 driver chip. The digital tube is a common cathode interface, which controls th
[Microcontroller]
Simulation and Program of Stepper Motor Controlled by STC89C52RC MCU
Realizing 8*8 LED heartbeat effect based on STC89c52 microcontroller
#include "reg51.h" //This file defines some special function registers of the microcontroller #include "intrins.h" typedef unsigned int u16; //declare and define the data type typedef unsigned char u8; sbit SRCLK=P3^6; //Use hc595 chip sbit RCLK=P3^5; //Use hc595 chip sbit SER=P3^4; //Use hc595 chip u8 leddua
[Microcontroller]
Design and research of heating temperature controller based on 89C51 single chip microcomputer and CAN bus
  The Ministry of Construction requires that newly built public and residential buildings in cities and towns that use centralized heating facilities must design and install heating systems with household metering and room temperature control functions. Energy-saving heating temperature controllers use automatic contr
[Microcontroller]
Design and research of heating temperature controller based on 89C51 single chip microcomputer and CAN bus
Research on PLC Based on AT89C55 Single Chip Microcomputer
With the rapid development of higher vocational education, the introduction of PLC technology into higher vocational education and as a more important course has reached a consensus in higher vocational education, which is an important measure for the modernization of curriculum construction. After studying the AT89
[Microcontroller]
Research on PLC Based on AT89C55 Single Chip Microcomputer
Design of intelligent charger based on UCC3895 and PIC microcontroller
Using the new generation of phase-shifted PWM control chip UCC3895 and PICl6F917 single-chip computer, an intelligent charger is designed and developed for commonly used lead-acid batteries. Its hardware design ideas and software implementation methods are introduced, and an intelligent control strategy is
[Industrial Control]
Design of intelligent charger based on UCC3895 and PIC microcontroller
AT89S5X ISP Download Cable Production
      For many microcontroller beginners, if they want to do some simple experiments by themselves, but they don't have much money to invest and can't afford a programmer. However, now the AT89S5X series microcontroller can download programs through the ISP download line, and the cost is very low, 10 yuan can do it.  
[Microcontroller]
AT89S5X ISP Download Cable Production
PC network experiment platform composed of single chip microcomputer and CS8900A
LAN technology is developing very rapidly, and Ethernet is currently the most widely used LAN technology. Therefore, learning Ethernet technology is very important for in-depth mastery of LAN knowledge. The course "Computer Network" is a computer and communication course offered by university computer and related ma
[Microcontroller]
51 MCU CS1237 electronic scale source program with detailed comments
Engineering hardware platform: 1, 51Core-V1.0 (51 single-chip minimum system board)                 2, differential ADC module-CS1237                 3, weighing sensor module                 4, OLED display 0.96 inches, 4PIN Engineering program version: 51 single-chip kitchen (pharmacy) scale solution V1.0.0.0
[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号