/******MCU multi-task template******/
#include
#define TASK_NUM 2 //Number of tasks
#define FRE(x) 10000/x //define frequency
unsigned char code s[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; //digital tube 0---9
unsigned int task_delay[TASK_NUM]; //Define the delay required for each task
unsigned int i=0;
void Init_Timer0(){
EA=1;
ET0=1;
TR0=1;
TMOD=0x02;
TH0=TL0=256-100; //12M crystal oscillator 10000Hz
}
void task0(){ // Task function
P0=~P0;
}
void task1(){ // Task function
P1=~P1;
}
void main(){
Init_Timer0();
while(1){
if(task_delay[0]==0){task0();task_delay[0]=FRE(1);} // Scan task function
if(task_delay[1]==0){task1();task_delay[1]=FRE(10);} // Scan task function
}
}
void timer0()interrupt 1{
for(i=0;i if(task_delay[i]) --task_delay[i]; }
Previous article:Several issues that should be noted in keil C
Next article:A non-preemptive operating system architecture based on C51 single-chip microcomputer
- 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
- 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
- Analysis and Design of TL431 Feedback Loop
- LSM6DSM iNEMO inertial module PCB package and code
- The problem of DC brushless motor UVW waveform without Hall connection
- 【TI recommended course】#Introduction to isolation topology#
- Regarding the situation where OBD multi-frame transmission fails to receive data
- Selling simulink models and TI28335 programs
- Infrared alarm circuit diagram
- EEWORLD University ---- Huawei IOT Internet of Things Tutorial
- [TI recommended course] #[High Precision Lab] ADC Series 5: ADC Frequency Domain Indicators#
- Please provide the equation for the LC series resonant circuit plus a rectangular wave, thank you.