#includesbit LED = P0^2; unsigned int vT = 0; void main () { LED = 0; // light up TMOD = 0x01; // Timing mode 1 16-bit timing counter TR0 = 1; // Start timer 0 TH0 = 0x3C; // Initial count value 15536 (65536-15536=50000 * 1us = 50ms) TL0 = 0xB0; while(1) { if (TF0 == 1) { TF0 = 0; // Clear the flag vT++; if (vT == 20) // 20 * 50 = 1000ms = 1s { vT = 0; TH0 = 0x3C; // Initial count value 15536 TL0 = 0xB0; LED = !LED; // Switch LED state after overflow } } } }
Previous article:Design of RS232-GPIB Controller
Next article:The first program lights up an LED
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- 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
MoreDaily News
- 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
Guess you like
- Finding hope in despair
- Please recommend a 48 to 12V DCDC step-down chip
- Happy Valley facility malfunctioned, many children were hanging upside down in the air~~
- [LAUNCHXL-CC2650] simple_peripheral routine analysis
- Is it a tax on IQ?
- CCS compilation error: unresolved symbols remain solution
- Fiber Optic Project Overview
- Bluetooth module problem
- Switching Power Supply Interest Group 13th Task
- Is the ST website down? Or is it crashing?