1. Target, PG13,PG14 dual-threaded dual flashing lights.
2. Test Platform
Keil v5.13.0.0
Cube 4.8.0
3. Steps
3.1 Open Cube, pg13,13 set as output, RCC Select External Crystal, click FreeRTOS
3.2 Clock Configuration Interface enable CSS, configured as System frequency 168M
3.3 All default settings, generate code.
3.4 Well-configured templates that's probably the case.
//void Startdefaulttask (void const * argument);intMainvoid) {hal_init (); Systemclock_config (); Mx_gpio_init (); Osthreaddef (Defaulttask, Startdefaulttask, Osprioritynormal,0, -); Defaulttaskhandle=osthreadcreate (Osthread (defaulttask), NULL); Oskernelstart (); while(1);}/*startdefaulttask function*/voidStartdefaulttask (void Const*argument) { /*USER CODE BEGIN 5*/ /*Infinite Loop*/ for(;;) {Osdelay (1); } /*USER CODE END 5*/ }
Tiger, just fill in your own code.
voidBLINK_LEDG (void Const*argument);voidBlink_ledr (void Const*argument); main () {Hal_gpio_writepin (Gpiog, gpio_pin_13, Gpio_pin_set); Hal_gpio_writepin (Gpiog, gpio_pin_14, Gpio_pin_set); Osthreaddef (Ledg, BLINK_LEDG, Osprioritynormal,0, -); Osthreaddef (Ledr, Blink_ledr, Osprioritynormal,0, -); Osthreadcreate (Osthread (LEDG), NULL); Osthreadcreate (Osthread (LEDR), NULL); Oskernelstart (); while(1); }voidBLINK_LEDG (void Const*argument) { for(;;) {Hal_gpio_writepin (Gpiog, gpio_pin_13, Gpio_pin_set); Osdelay ( -); Hal_gpio_writepin (Gpiog, gpio_pin_13, Gpio_pin_reset); Osdelay ( -); } }voidBlink_ledr (void Const*argument) { for(;;) {Hal_gpio_writepin (Gpiog, gpio_pin_14, Gpio_pin_set); Osdelay ( -); Hal_gpio_writepin (Gpiog, gpio_pin_14, Gpio_pin_reset); Osdelay ( -); } }
Create a FreeRTOS project with STM32CUBEMX