I.说明
作者:WXP(翱翔云端的鸟)
联系方式:328452854@qq.com || 13100610853(联系请注明CSDN)
申明:个人原创,转载请先经过本人同意!
要说的话:个人水平有限,不足之处,还请指正!有疑问欢迎大家联系我交流探讨!
=============================================================================================================================
=============================================================================================================================
II.环境
软件环境:KEIL-MDK v-5.24a
硬件:STM32F103ZET6最小系统板
=============================================================================================================================
=============================================================================================================================
III.FreeRTOS简介
FreeRTOS作为一个RTOS(Real Time Operating System),Free,即免费。公司或者个人在自己的产品中使用了FreeRTOS而不必为各种授权问题而苦恼! 这也是相对其它嵌入式RTOS的优势。其次它十分精简短小,占用很小的空间(4-9K字节大小),同时它支持很多平台,官方的文档也相对比较齐全,上手比较容易,所以比较适合初次接触RTOS的工程师。
FreeRTOS的具体特点如下
1.免商业许可,可以在具体产品中免费试用FreeRTOS
2.支持众多半导体厂家的平台,应用范围广,资料齐全
3.相比较于其它OS,代码更精简,移植更容易
4.提供了一个用于低功耗的Tickless模式
5.任务数量不受限制
6.内部有软件定时器和堆栈检测功能
7.内核对象齐全,在任务同步通信中使用起来很方便
=============================================================================================================================
=============================================================================================================================
IV.移植FreeRTOS到STM32F103平台
1.准备FreeRTOS源码和一个裸机STM32-Demo程序(STM32F103ZET6),FreeRTOS源码可以在官网www.freertos.org下载,同时上面也可以下载到很多文档。
这里我给出我的百度云下载地址(FreeRTOS源码和STM32裸机Demo):http://pan.baidu.com/s/1nvuTOPN
2.查看FreeRTOS源码目录,分为Demo、License、Source 3个目录
Demo目录下存放的是FreeRTOS的相关历程 如下图:
LICENSE目录是FreeRTOS的许可,可以不看
Source就是真正的FreeRTOS的源码目录
目录视图如下:
可以看到Source目录文件也很少,两个目录和一些.c文件 。
include:FreeRTOS的头文件
protable:平台及编译环境所需要的移植文件
xxx.c FreeRTOS源文件
这里我们只需注意 protable目录下的部分文件,这部分文件是等下移植所需要用到的
Keil:MDK编译环境所需要的文件
MemMang:内存管理相关文件,移植必须
RVDS:MDK编译环境所需要的文件
3.在裸机Demo工程文件中新建一个FreeRTOS的文件夹,并将FreeRTOS的源码全部添加到这个文件夹当中
如图所示:
4.删除protable目录下除Keil MemMang和RVDS外的所有文件
5.在MDK中新添加两个分组 FreeRTOS_Source和FreeRTOS_Ports,并添加对应的文件
{ croutine.c
FreeRTOS_Source { event_groups.c
{ list.c
{ queue.c
{ task.c
{ timers.c
FreeRTOS_Ports { port.c RVDS/ARM_CM3目录下
{heap_4.c MemMang目录下
{portmacro.h RVDS/ARM_CM3目录下 这里添加.h是为了比较容易查看
添加完成后如下图:
5.添加对应的文件路径 ..FreeRTOSinclude..FreeRTOSportableRVDSARM_CM3
如图所示
6.编译,提示缺少FreeRTOSConfig.h文件
7.这里我们有两种方法添加这个文件,一种是自己创建,这个会很麻烦对于不懂FreeRTOS的人来说很难。第二种就是直接去官方移植好的例程中找到这个文件
这里推荐第二种 FreeRTOSv9.0.0->FreeRTOS->Demo->CORTEX_STM32F103_Keil 中找到FreeRTOSConfig.h
然后复制到裸机工程的USER目录下
如图
8.然后将FreeRTOSConfig.h文件添加到MDK USER组中(这里是为了容易查看和修改)
9.修改stm32f10x_it.c
修改bsp_systick.c
修改bsp.c如下
10.添加一个includes.h 用来管理所有的头文件
#ifndef __INCLUDES_H__
#define __INCLUDES_H__
/***********************************************************************************
* STD
************************************************************************************/
#include #include #include #include #include "stm32f10x.h" /************************************************************************************ * OS *************************************************************************************/ #include "FreeRTOS.h" #include "task.h" #include "queue.h" #include "croutine.h" /************************************************************************************ * MACRO DEFINE *************************************************************************************/ /************************************************************************************ * APP/BSP *************************************************************************************/ #include "bsp.h" #endif 11.修改FreeRTOSConfig.h和main.c FreeRTOSConfig.h /* FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. This file is part of the FreeRTOS distribution. FreeRTOS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (version 2) as published by the Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception. *************************************************************************** >>! NOTE: The modification to the GPL is included to allow you to !<< >>! distribute a combined work that includes FreeRTOS without being !<< >>! obliged to provide the source code for proprietary components !<< >>! outside of the FreeRTOS kernel. !<< *************************************************************************** FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Full license text is available on the following link: http://www.freertos.org/a00114.html *************************************************************************** * * * FreeRTOS provides completely free yet professionally developed, * * robust, strictly quality controlled, supported, and cross * * platform software that is more than just the market leader, it * * is the industry's de facto standard. * * * * Help yourself get started quickly while simultaneously helping * * to support the FreeRTOS project by purchasing a FreeRTOS * * tutorial book, reference manual, or both: * * http://www.FreeRTOS.org/Documentation * * * *************************************************************************** http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading the FAQ page "My application does not run, what could be wrong?". Have you defined configASSERT()? http://www.FreeRTOS.org/support - In return for receiving this top quality embedded software for free we request you assist our global community by participating in the support forum. http://www.FreeRTOS.org/training - Investing in training allows your team to be as productive as possible as early as possible. Now you can receive FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers Ltd, and the world's leading authority on the world's leading RTOS. http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, including FreeRTOS+Trace - an indispensable productivity tool, a DOS compatible FAT file system, and our tiny thread aware UDP/IP stack. http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS licenses offer ticketed support, indemnification and commercial middleware. http://www.SafeRTOS.com - High Integrity Systems also provide a safety engineered and independently SIL3 certified version for use in safety and mission critical applications that require provable dependability. 1 tab == 4 spaces! */ #ifndef FREERTOS_CONFIG_H #define FREERTOS_CONFIG_H /*----------------------------------------------------------- * Application specific definitions. * * These definitions should be adjusted for your particular hardware and * application requirements. * * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. * * See http://www.freertos.org/a00110.html. *----------------------------------------------------------*/ //抢占式调度使能 1--ENABLE 0--DISABLE #define configUSE_PREEMPTION 1 // #define configUSE_IDLE_HOOK 0 #define configUSE_TICK_HOOK 0
上一篇:STM32原有的MDK工程下移植到GCC环境
下一篇:STM32+freeRTOS学习笔记-1.使用cube MX创建一个freeRTOS的keil工程
推荐阅读最新更新时间:2024-11-05 11:41
设计资源 培训 开发板 精华推荐
- 【CW32】自律定时器
- DC230A-B,使用 LT1533CS 12Vin 至 ±5Vout @ 700mA、10.8Vin、3.5W 输出超低噪声双极输出 DC/DC 转换器的演示板
- 使用 Diodes Incorporated 的 PT8A 3516C 的参考设计
- VAR-DVK-AM33_PRO_CO,基于 VAR-SOM-AM33 的开发套件,带有 7 LCD 电容式触摸面板和 Windows Embedded Compact 7
- MAXREFDES1210:96W、12V 两相 SEPIC,使用 MAX16990
- 实时姿态显示TREBLE
- 用于电机控制的 12V 模拟放大器
- 87 无灯雷蛇键盘
- 四合一电调
- EFM8BB1-SLSTK2020A,用于 EFM8BB1 Busy Bee MCU 的 EFM8 入门套件