Create a FreeRTOS project with STM32CUBEMX

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.