The C language code is as follows:
/*----------------------------------------------------------------------
Function: Software precise delay
Descripton: One is to use the three single-cycle instructions of C51, assignment, comparison, and decrement, to implement software delay;
Another method is to use the C51 library function _nop_() software to delay a machine cycle.
System crystal frequency: 11.0592MHz
Author: Zhang Kaizhou
Date: 2019-6-19 11:51:55
-----------------------------------------------------------------------*/
#include #include #define uchar unsigned char #define uint unsigned int void main(){ uint i; // The delay length range can be expanded by changing the data type of i i = 100; while(i) i--; /* Delay length = 10.85 + (i - 1) * 8.68; Then i = ((delay length - 10.85) / 8.68) + 1; For example: if the delay is 60us, then i = (60 - 10.85) / 8.68 + 1 = 7; (When the value of i is rounded up, the delay will be slightly longer than the target duration [2 machine cycles]; (When the value of i is rounded down, the delay will be slightly less than the target duration [2 machine cycles]) */ _nop_(); // Delay one machine cycle 1.08us while(1); }
Previous article:LCD1602 Display Summary
Next article:The single chip microcomputer controls the DC motor to achieve various motion combinations
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- I would like to ask if any of you experts have made a LED controller for a lottery turntable, or can help develop such a controller 18588252018
- 【AT-START-F425 Review】Review Summary
- What does the EAS test of the chip mean and what is its function? Please give me some advice
- gcc linaro cross-compilation tool download address
- Help: RSL10 RAM can only use 24KB, why can't the remaining 6x8KB be used? - Problem Solved
- Synopsys IP Resources: A look at the complete Ethernet PHY IP for high-performance computing SoCs
- What is Common Mode Rejection Ratio (CMRR)
- High Definition Smith Chart Black and White_the_Smith_Chart.
- Is there any difference between these two circuits?
- Help~How can I make the PCB package of this component according to the picture?