#include
typedef unsigned char u8;
typedef unsigned int u16;
sbit led = P1^0;
u8 timer;
void main (void)
{
TMOD = 0x01; //Set TMOD to make T0 work in 16-bit timing.
TH0 = (65535-50000) / 256;
TL0 = (65535-50000) % 256;
EA = 1; //Open the total interrupt
ET0 = 1; //Open the overflow interrupt of timer 0
TR0 = 1; //Start timing
while(1) //The function is to end the program, otherwise the program will keep running here;
{
;
}
}
//Implementation method 1
void timer0_service(void) interrupt 1
{
TH0 = (65535-50000) / 256;
TL0 = (65535-50000) % 256;
//50ms has been set
timer ++;
if (timer == 20)
{
timer = 0;
led = ~led;
}
}
/**************************** Stay hungry, Stay foolish. @Rocky**************** **********/
Previous article:Talking about static digital tube
Next article:External interrupt experiment
Recommended ReadingLatest update time:2024-11-15 16:39
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
- Animation demonstration of capacitor working principle, charging and discharging experiment, capacitor filtering principle
- Timer and digital tube
- Can a motor burn out even if it has inverter protection? How to avoid it?
- Power supply slow start principle
- The learning journey of an electronics novice... Updated irregularly every year
- Tkinter Study Notes (Part 3)
- Spectrum Analyzer Test Noise Figure Calibration
- Thinkpad Advanced Docking Station 40A80045CN Disassembly & Minor Modification (1)
- TI millimeter wave radar learning website link summary
- [Hua Diao Experience] 04 Test the common functions of the Xingkong board