Purpose: To control the delay through the timer interrupt to reverse the state of the first LED
The circuit diagram of the development board MUC and LED module is as follows:
For the key points about timers and counters, please refer to: https://blog.csdn.net/cax1165/article/details/86659302
For the key points about interruption, please refer to: https://blog.csdn.net/cax1165/article/details/86633086
#include #define uc unsigned char sbit led=P2^0; void timeint0() { TMOD=0X01; //Working mode TH0=0XFC; //Timing 1ms TL0=0X18; //timing 1ms TR0=1;//control ET0=1; //Timer 0 interrupt request EA=1; //Total interrupt } void time0int () interrupt 1 //Note the interrupt number { static int i=0;//Note the use of static variables! TH0=0XFC; //Timer reset TL0=0X18; //Timer reset i++; if(i==1000) //1000 1ms make up 1s { i=0; led=~led; //led state inversion } } void main() { timeint0(); while(1); }
Previous article:51 MCU Experiment 11: Serial Communication
Next article:51 MCU resources - EEPROM (IIC bus)
- 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
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- How connected vehicles process data: 3 common questions
- [Jihai APM32E103VET6S development board] Evaluation 2, Development environment
- [EVK-NINA-B400 Evaluation Kit] + First Meeting
- msp430 LCD driver module
- How to use high-speed ADCs and DACs with FPGAs
- 618 What did you buy?
- Vicor's better power supply increases drone flight time, radius and payload
- MATLAB Neural Network Principles and Examples
- Bluetooth wireless technology protocol types
- Using the sensor hub mode of lsm6dsl to drive lis2mdl output data unchanged