|
【STM32F429心得\疑问】+最新FreeRtos(版本8.0)上手指南# x- \3 G& U* ?$ I) Z9 h. b 最近折腾一块stm32f107rc的板子,摸索了一下FreeRTOS 的使用 发现起步不太难有点经验和大家分享。 1,先从官网http://www.freertos.org/下载 FreeRTOS 8.0.0 2,用标准库(STM32F10x_StdPeriph_Lib_V3.5.0)模板建工程( P6 E- [. B0 Q' W" f$ X 3, 在工程中添加FreeRTOS 文件。tasks.c list.c queue.c heap_2.c port.c 其中port.C是cotex M3的移植文件。选择目录..\..\Source\portable\RVDS\ARM_CM3\/ ^9 k% d4 t) J( A! N2 C3 u& p 下的port.c8 f/ L% M: U5 U9 ^$ I! G . x& @% ^2 J5 z$ D# ^* d 3,修改启动代码(.s文件)如下,主要是链接FreeRTOS的三个中断函数6 _& p& x6 r& v, K$ t( ` [4 e7 M8 [- C IMPORT xPortPendSVHandler IMPORT xPortSysTickHandler# M2 H* ~7 }8 v5 \# {# u" b IMPORT vPortSVCHandler/ j* s6 q s2 c$ N ..... DCD vPortSVCHandler ; SVCall Handler DCD DebugMon_Handler ; Debug Monitor Handler DCD 0 ; Reserved6 m- S0 n& v0 B9 c DCD xPortPendSVHandler ; PendSV Handler3 P/ {, x! I3 j% Q& U8 n+ [) } DCD xPortSysTickHandler ; SysTick Handler 4.在main中建立自己任务开始 rtos 3 h% q; W- ^# M) w& T /* Create one task. */. L, U5 q' H6 v' k3 U% \$ ] xTaskCreate( vTask1, /* Pointer to the function that implements the task. */ "Task 1", /* Text name for the task. This is to facilitate debugging only. */ 200, /* Stack depth in words. */$ A5 B3 j# E& C7 p7 B+ N NULL, /* We are not using the task parameter. */: k* t4 J4 n: ? s8 t1 Q+ n 1, /* This task will run at priority 1. */6 l! w" a* o- s& c NULL ); /* We are not using the task handle. */5 c$ F1 H; r, n5 _; @5 N /* Create one task. */1 u/ U5 } Z; z+ F' T! A. z xTaskCreate( vTask2, /* Pointer to the function that implements the task. */ "Task 2", /* Text name for the task. This is to facilitate debugging only. */( s6 [7 w( a, \ 200, /* Stack depth in words. */ NULL, /* We are not using the task parameter. */ 2, /* This task will run at priority 1. */- Q! `/ _% Y! j. X6 ~3 ^( X: a NULL ); /* We are not using the task handle. */ /* Start the scheduler so our tasks start executing. */ vTaskStartScheduler(); ..............! s0 b& M3 ?: q# D .............. void vTask1( void *pvParameters ) { /* As per most tasks, this task is implemented in an infinite loop. */7 x6 b( t# f" D, O2 u0 R while(1) { LED_Toggle(0); LED_Toggle(2); vTaskDelay(800); } } void vTask2( void *pvParameters ) {( Y: x; u. `8 q# P* y /* As per most tasks, this task is implemented in an infinite loop. */ while(1); \7 E8 X' ]0 J) f { LED_Toggle(1);/ r3 D; z$ S0 ^5 I& a- r LED_Toggle(3);* W9 F$ ]! F. v- o- d vTaskDelay(1600);7 V1 P8 R/ s- @ } U. V. d- q8 |# l" O" r( | } |
【福利三:雨露均沾·逢7狂欢】之四:用一个定时器同步另外两个定时器输出PWM
【逢7发帖赢大礼】STM32开发之WIFI实时时钟
【逢7发帖赢大礼】STM32开发之指纹识别!
【逢7发帖赢大礼】STM32开发之环境空气质量监测
【逢7发帖赢大礼】STM32开发之人体实时运动信息监测!
【逢7发帖赢大礼】STM32开发之IC门禁卡UID读取方法!
【逢7发帖赢大礼】全网最简单的Arduino_STM32开发环境搭建教程!
STM32F4中文用户手册
STM32F400、STM32F402 Cortex-M4超值单片机
SPI 高温读错最后一位?STM32F42xx 官方根治方案
微信公众号
手机版