void Delayms(unsigned int n)
{
unsigned int i,j;
for(j=n;j>0;j--)
for(i=112;i>0;i--);
}
Use keil to see the delay time. Let’s delay for 1ms first (Delayms(1)).
Before entering Delayms, sec=0.00042209s
After delay, sec=0.00142253s
It can be known that the actual delay of Delayms (1) is 0.00142253s-0.00042209s=0.00100044s≈1ms
Similarly, if you want to delay for 15ms, use Delayms(15). The actual delay is 0.01480903s≈15ms, which is quite accurate.
Previous article:51 MCU serial port debugging program
Next article:51 MCU interrupt number corresponding to the interrupt
- 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
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- The story I have to tell about Yatli+!
- Misuse of "termination" will cause signal failure
- Raspberry Pi Pico is out~ I originally said that I would not review it before the New Year, but I am here to recommend this board to you~~
- PyBoard W5500 firmware compilation issue
- Discussion and help
- "Playing with the board" + lighting up the SPI touch screen of Xintao
- &FF0000 and &880000 are both red. What is the difference between these two reds?
- Internet radio design based on RSIC-V RVB2601 (3)
- LIS2MDL three-axis magnetometer package and code
- Live broadcast with prizes: Enter the TI robot production class, starting on Friday, reservations are in progress! (Share 100% to get gifts)