Study on STC12 delay function

Publisher:EternalSunsetLatest update time:2021-03-25 Source: eefocusKeywords:STC12 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This writing method is to nest assembly in C. The exact delay time = 2*t*T+5*T, T is one machine cycle. For 8051,



If t=1, then the execution of this function should be 7us. If it is STC12, then the delay of this delay function should be: if t=1, the precise delay = 2*1*1/12+5*1/12=(7/12)us.


I checked the STC12 manual yesterday. The manual describes the clock in a very general way. One sentence is: Compared with the execution time of 8051 instructions, there are 12 instructions in total, which can be executed in one clock, and the operation speed is increased by 8 to 12 times at the same frequency.

Should it be (7/8)us? Instead of (7/12)us?

This is a uint type function and the time is approximate

Then you can use delay time = 8*t*T

It should be 8*1*(1/12)=8/12

According to the program analysis, it is conjectured that the delay function should be 1us when t=1, which is the most reasonable.

Using an oscilloscope to test, it takes about 5.8ms to execute a delay (5000). 51 It takes about 40064us to execute a delay (5000). Well, using an oscilloscope to measure the frequency change of the IO port is 85.47HZ, so a delay (5000) is (1/85.47)/2*1000=5850us

Here, t is set to uint type, which has errors. In addition, the execution of LED=1;LED=0; will also consume time and result in errors.

Finally, it is concluded that this delay statement takes about 7us to execute once on 51 and 1us on 12. The oscilloscope test passed! It is consistent with my calculation.


Keywords:STC12 Reference address:Study on STC12 delay function

Previous article:51 single chip microcomputer realizes infrared coding detection
Next article:The influence of crystal oscillator on baud rate in single chip microcomputer

Recommended ReadingLatest update time:2024-11-23 11:21

Design solution of multi-protocol bus integrator based on C8051F120
Since industrial fieldbus has been widely used in industrial control, intelligent instrumentation, data acquisition, etc., the demand for bus integration has also emerged. Different types of fieldbus protocols focus on their respective application areas, resulting in products based on various fieldbuses being unable t
[Microcontroller]
Design solution of multi-protocol bus integrator based on C8051F120
C8051F MCU Emulator and Development Board FAQs
Question 1: Why can my emulator be recognized, but cannot simulate, debug or download the program?  Answer: The emulator can be recognized, which proves that the emulator is good. The failure to simulate, debug or download the program has the following two reasons: 1. Whether the hardware path is normal. Check the fo
[Microcontroller]
C8051F LCD1602 Program
摘要: /********************************************************************************************************** File : LCD1602.c* Hardware Environment: DVK501 F320 EX* Build Environment : Silicon LABs 3. ... /******************************************************************************************************** * * F
[Microcontroller]
Design and application research of memory oscilloscope based on enhanced 8051 microcontroller
1 Introduction The oscilloscope is a basic instrument for electronic measurements. Due to its real-time, intuitive and vivid graphics display characteristics, it is also one of the commonly used instruments in general physics laboratories. As we all know, oscilloscopes are made based on the principles of input voltage
[Microcontroller]
Design and application research of memory oscilloscope based on enhanced 8051 microcontroller
Multi-bank partition jump processing in C8051 F12X
In the huge family of 8051 core microcontrollers, the C8051F series, as a rising star, is one of the most fully functional and fastest 8051 derivative microcontrollers and is being used more and more widely. It integrates many advanced technologies of embedded systems and has rich analog and digital resources. It i
[Microcontroller]
Multi-bank partition jump processing in C8051 F12X
Small resistance tester based on C8051F005 single chip microcomputer
1. Introduction In the process of circuit testing, it is often encountered that due to the neglect of the influence of certain small resistors, there is a large error between the experimental data and the theoretical value, which affects the test effect. For example, copper resistance often exists in ind
[Microcontroller]
Small resistance tester based on C8051F005 single chip microcomputer
8051 and ESP32 CAM serial communication
Earlier we introduced the serial communication of 8051 and had a certain understanding of serial communication. Now let's implement the communication between 8051 and ESP32CAM. First, understand the pin diagram of esp32 cam. As shown in the figure above, we can see that the serial port 0 pins of ESP32 CAM are GPIO
[Microcontroller]
8051 and ESP32 CAM serial communication
Design of a dual-channel shaft angle measurement experimental device based on C8051F021
0 Introduction 现代电子技术的进步不断推动数字伺服系统的发展,人们对位置角度测量提出了越来越高的要求。轴角转换装置旋转变压器以其高精度、抗震动、高可靠性著称,在工业控制和武器控制系统等设备中应用广泛。为了促进学员对旋转变压器角度转换、测量和通过双通道粗精组合提高测量角度精度的原理和技术的掌握,在不需要复杂的外围设备情况下,利用C8051F021混合型芯片内置的集成12位ADC与DAC,方便的实现激励信号产生、正余弦信号测量、轴角计算,同时,C8051F021对C语言编程有较好的支持能力,利用C语言编程,可以方便的实现程控。基于此,设计本实验装置。 1 System Design
[Microcontroller]
Latest Microcontroller Articles
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号