/*
Effect description:
Counter interrupt: program execution through external count
Press the interrupt button once, the upper four bits will light up when the interrupt occurs, and the program will return to the main program after the interrupt occurs.
*/
#include
#include
unsigned int i;
void delay()//delay sub-function
{
i=50000;
while(i--);
}
//unsigned char TCOM;
//Interrupt initialization
void center1()
{
ET0 = 1; //Start the counter interrupt switch
EA = 1; // Main switch
/*
The core of the counter is here
*/
TH0 = 255; // press once to interrupt
TL0 = 255;
TMOD = 0x05; //0000 0101 in counter mode
TR0 = 1; //Start the timer
}
void main()//main function
{
zhongduan1(); //Interrupt initialization
while(1) //while infinite loop, the main program keeps executing, that is, the lower four bits are always on, when an interrupt occurs, the interrupt function program is executed, and after the interrupt occurs, it returns to the main program
{
P0 = 0xf0; //light up the lower four bits
}
}
//The interrupt program is the program to be executed after the interrupt
void zhongduan() interrupt 1
{
P0 = ~0xf0; //high four bits are bright
delay(); //delay sub-function call is converted into the time to execute the program when the interrupt occurs
TH0 = 255;
TL0 = 255;
}
Previous article:Timer/Counter 0 (Timer)
Next article:80C31 MCU external interrupt 0
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- EEWORLD University - How to repair damaged printed lines
- [Environmental Expert's Smart Watch] Part 17: Watch Modeling and Animation
- Thank you for your partnership
- NUCLEO-G431RB Review -> COMP
- ST MEMS Device Resource Library - ST MEMS Sensor Design Application Guide and Frequently Asked Questions (FAQ)
- EEWORLD University ---- Texas Instruments SimpleLink? Wi-Fi Solution
- Qinheng CH32V103 Review Summary
- Motor stroke control problem
- Help with the angle, acceleration conversion and accuracy of LSM6DSM
- Urgently looking for chip model