Keil ARTX (Advanced Real-Time eXecutive) is a small real-time operating system provided by Keil for the ARM series, integrated into its UV3 development environment. After downloading and installing the RealView MDK personal learning version, ARTX is also installed in the C:KeilARMRLRTX directory. There are STM32 example programs in the C:KeilARMBoardsKeilMCBSTM32STLIB_RTX_Blinky directory. After simple modification, it runs on the Wanli development board.
#include
#include
OS_TID t_phaseA; //Assign task ID number
OS_TID t_phaseB;
OS_TID t_phaseC;
OS_TID t_phaseD;
#define LED_A GPIO_Pin_4
#define LED_B GPIO_Pin_5
#define LED_C GPIO_Pin_6
#define LED_D GPIO_Pin_7
#define LED_On(led) GPIO_SetBits(GPIOC , led)
#define LED_Off(led) GPIO_ResetBits(GPIOC, led)
extern void SetupClock (void);
extern void SetupLED (void);
void phaseA (void) __task {
for (;;) {
LED_On (LED_A);
os_dly_wait (100);
LED_Off(LED_A);
os_dly_wait (100);
}
}
void phaseB (vo id) __task {
for (;;) {
LED_On (LED_B);
os_dly_wait (100);
LED_Off(LED_B);
os_dly_wait (100);
}
}
void phaseC (void) __task {
for (;;) {
LED_On (LED_C);
os_dly_wait (100);
LED_Off(LED_C);
os_dly_wait (1 00);
}
} void
phaseD (void) __task {
for (;;) {
LED_On (LED_D);
os_dly_wait (100);
LED_Off(LED_D);
os_dly_wait (100);
}
}
void init (void) __task {
t_phaseA = os_tsk_create (phaseA, 0);
os_dly_wait (50);
t_phaseB = os_tsk_create (phaseB, 0);
os_dly_wait (50);
t_phaseC = os_tsk_create (phaseC, 0);
os_dly_wait (50);
t_phaseD = os_tsk_create (phaseD, 0);
os_tsk_delete_self ();
}
int main (void) {
SetupClock();
SetupLED ();
os_sys_init (init);
}
After the initialization, os_sys_init (init) starts the initialization task. In the initialization task, 4 tasks are started one after another. After starting,
Delete the initialization task. These four tasks each control the switch of an LED.
============================================
Personal understanding:
int main(void)
{
}
Question 1: Why don't we call the os_sys_init_user() API after creating many small tasks in TaskMain? The reason is that after initializing TaskMain, it does not return, so it cannot execute the while statement below
Q2: TaskMain creates small tasks, and each small task has a while(1) infinite loop, which is the concept of multithreading. Except for while(1), all other functions are executed only once, including the variables in the main function and small tasks. Only while(1) runs with time slices and priorities, realizing multithreaded execution.
Previous article:Understanding the tasks of RTL creation
Next article:STM32 SYSTICK
Recommended ReadingLatest update time:2024-11-16 21:27
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- How should I find the development board schematics and PCBs of major manufacturers?
- EEWORLD University ---- Wireless Power 101
- TI combines Bluetooth solution with MSP430 microcontroller
- [Erha Image Recognition Artificial Intelligence Vision Sensor] Evaluation 5: Erha Image Recognition Object Recognition
- What are the differences between wire-wound common mode inductors and chip-wound inductors?
- 【Live Replay Summary】Microchip ShieldsUP! Security Solutions Online Seminar Series (18 sessions)
- Lua script development based on serial port screen - use of pi
- NU510 can control the light strip without single chip microcomputer, dual color temperature dimming and color flow light
- TI mmWave Radar MIMO (2TX4RX) Setup
- [STM32MP157C-EV1] After the first unboxing and evaluation, I will run rtt on it and share other