STM32学习笔记(1)如何移植FreeRTOS

STM32固体库创建demo

下载相关文件

keil5下载地址:keil5

下载相关的pack包:Keil.STM32F1xx_DFP.2.1.0.pack

移植所需的freertos源码:FreeRTOSv9.0.0.exe

移植所需的STM32固件库:STM32F10x_StdPeriph_Lib_V3.5.0.rar

建立固体库项目

建立如下图所示的项目组:

BSP目录放相关的driver.

FreeRTOS目录将放置我们所需移植的东西

Libraries目录将防止我们固体库所需的代码如下:

USER放置main函数,并放置一些用户自己定制的一些文件

如何真的进行相关的操作可以参考STM32F1开发指南-库函数版本_V3.1 .pdf的第三章

差不多准备工作完成了,下面重点就是如何移植FreeRTOSv9.0.0

移植FreeRTOSv9.0.0到STM32F103中

1.1打开解压后点源码

1.2双击打开“FreeRTOS”文件夹,看到如下文件

图中圈圈的就是源码了,整个文件夹拷贝到新建工程的“FreeRTOS”文件夹中

1.3在源码文件夹中**\FreeRTOS\Demo\CORTEX_STM32F103_Keil这个路径下,找到文件FreeRTOSConfig.h**,拷贝到工程文件夹FreeRTOS中

1.4打开keil,添加文件

添加文件如上如所示

“port.c”文件路径…\FreeRTOS\Source\portable\RVDS\ARM_CM3

“heap_2.c”文件路径…\FreeRTOS\Source\portable\MemMang

“list.c”、“queue.c”、“tasks.c”文件路径…\FreeRTOS\Source

1.5添加头文件

注意填入:STM32F10X_HD,USE_STDPERIPH_DRIVER

1.6修改main函数

#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "misc.h"

#include "led.h"


void LED0_Task(void * pvParameters);
void LED1_Task(void * pvParameters);

int main(void)
{
	LED_Init();
	
	xTaskCreate(LED0_Task, (const char *)"LED0", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 3, NULL);
	xTaskCreate(LED1_Task, (const char *)"LED1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 4, NULL);
	
	vTaskStartScheduler();
}

void LED0_Task(void * pvParameters)
{
	while (1)
	{
		LED0 = !LED0;
		vTaskDelay(800 / portTICK_RATE_MS);
	}
}

void LED1_Task(void * pvParameters)
{
	while (1)
	{
		LED1 = !LED1;
		vTaskDelay(500 / portTICK_RATE_MS);
	}
}
1.7修改启动文件

遇到问题

在移植过程中难免有错误。需要我们去解决

问题一 编译

…\OBJ\FreeRTOS.axf: Error: L6218E: Undefined symbol vApplicationTickHook (referred from tasks.o).

可以选择在BSP目录下添加相关的程序代码。

void vApplicationTickHook(void)
{
  
}

关于项目

本项目在github上已经有了,可以从我的github上进行下载。

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
STMicroelectronics STM32F1 Series Device Support, Drivers and Examples Version: 2.1.0 Keil.STM32F1xx_DFP.2.1.0.pack Updated CMSIS drivers: EMAC: Improved robustness by function checking that driver is powered (EMAC_FLAG_POWER) CAN: Corrected functionality when only one CAN controller is used Corrected pin remap configuration for CAN2 port pins Corrected functionality when NULL pointer is provided for one or both signal callbacks in Initialize function USB Device: Corrected Isochronous transfer Corrected IN Endpoint FIFO flush procedure USB Host: Removed interrupt priority handling Corrected multiple packet sending Corrected PowerControl function for unconditional Power Off USART: Corrected Peripheral Reset and Clock enable/disable (check if peripheral is available on selected device) Corrected CTS handling and added signal CTS change event. SPI: Corrected Peripheral Reset and Clock enable/disable (check if peripheral is available on selected device) Corrected Bus Speed configuration Corrected 8bit/16bit Data register access, regarding the Data frame size -I2C: Corrected invalid __I2C_DMA field in I2C_DMA_TxEvent and I2C_DMA_RxEvent functions Updated/added examples: Added examples using Network DualStack (IPv4/IPv6) Middleware targeting MCBSTM32C (Keil.MDK-Middleware.7.0.0.pack required) Updated emWin examples to emWin V5.32 Updated CAN examples Updated USB Host examples Updated USB Device CDC ACM VirtualCOM examples Updated RTE_Device.h: Corrected USART Pin configuration Added trace configuration to the debug description and updated Quick Start Guide

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值