Nucleo-L476 run FreeRTOS learning 1

 

Holidays at home due to the pneumonia epidemic raging, learning things in a professional point in the rental inside, began to try to write a blog to record their learning process.

Do today is preliminary run on the ST official produced Nucleo-L476 Free RTOS

  •  Use hardware + software tools

Hardware platform using Nucleo-L476

Official information see: https://www.st.com/zh/evaluation-tools/nucleo-l476rg.html

Board LED, LD3 for the power indicator (LD2 can control our own)

Engineering and drive the underlying code using CubeMX5.3.0 generation (eliminating the need for the establishment of the project and the underlying drivers written), code development tools Keil5.25.2

  • Establish engineering

New project, select the board model, Start Project

(While the Cube X Interface board will complement the resources instructions, user manuals, access is very convenient)

 

Select Yes, use the default board peripheral configuration

Can be seen, peripheral pin have a default configuration (including a clock, the IO external, serial port configuration)

  • Project Configuration

Clock has the LSE default selection (external low), X2 may be bonded to the crystal oscillator schematic welding kanban (X3 external high-speed unsoldered)

Download the debug mode for the SW (onboard STLink)

Choose to use the Free RTOS

Choose to use FreeRTOS

Here are some of the configuration FreeRTOS

  • Task of building

Add two tasks, a blinking LED for myTask_LED, serial print data for a myTask_USART

Generating code configuration according to their own

Click to generate code appears:

Here is recommended to use a timer to generate said system clock signal, we re-allocation, the system clock source, selected as a timer 1

Click again to generate code

Open project

  • Code changes

First look to see whether the compiler error (compilation process is relatively slow)

We only need to fill out two tasks just created code

LED writing task

/* USER CODE END Header_StartTaskLED */
void StartTaskLED(void *argument)
{
  /* USER CODE BEGIN StartTaskLED */
  /* Infinite loop */
  for(;;)
  {
	//翻转LED电平
	HAL_GPIO_TogglePin(GPIOA,5);
    osDelay(500);
  }
  /* USER CODE END StartTaskLED */
}

/* USER CODE BEGIN Header_StartTaskUSART */
/**
* @brief Function implementing the myTask_USART thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartTaskUSART */
void StartTaskUSART(void *argument)
{
  uint8_t UART_BUF[14] = "Hello FreeRTOS";
  /* USER CODE BEGIN StartTaskUSART */
  /* Infinite loop */
  for(;;)
  {
	HAL_UART_Transmit(&huart2,UART_BUF,14,0xffff);
    osDelay(1000);
  }
  /* USER CODE END StartTaskUSART */
}

Downloaded to the board seen results

后续将研究Free RTOS各配置和功能。

 

 

 

 

发布了1 篇原创文章 · 获赞 0 · 访问量 21

Guess you like

Origin blog.csdn.net/Paul_Yu_Zhang/article/details/104233028