
【STM32F429心得\疑问】+最新FreeRtos(版本8.0)上手指南 最近折腾一块stm32f107rc的板子,摸索了一下FreeRTOS 的使用+ `9 l! n9 K+ W( @( e 发现起步不太难有点经验和大家分享。; U3 k& H: y8 v% F' G1 z3 Q 1,先从官网http://www.freertos.org/下载 FreeRTOS 8.0.0 4 B6 u( {2 q* L" _. h1 m+ q 2,用标准库(STM32F10x_StdPeriph_Lib_V3.5.0)模板建工程4 C; S0 d. e9 U/ `0 _) D7 q; O: ^ 3, 在工程中添加FreeRTOS 文件。tasks.c list.c queue.c heap_2.c3 J) L, a" V( m+ S6 h; j, b4 A port.c 其中port.C是cotex M3的移植文件。选择目录..\..\Source\portable\RVDS\ARM_CM3\7 p. `2 G% [! [) X* {% D' Y" a 下的port.c ! H2 n9 g& j3 [( ` P V) M 3,修改启动代码(.s文件)如下,主要是链接FreeRTOS的三个中断函数" r8 C0 G' n8 @' _ @3 P9 y l* D6 |- |! \$ u3 K IMPORT xPortPendSVHandler IMPORT xPortSysTickHandler1 c+ t9 q9 k6 f2 P7 N; e7 k: o IMPORT vPortSVCHandler ..... DCD vPortSVCHandler ; SVCall Handler DCD DebugMon_Handler ; Debug Monitor Handler DCD 0 ; Reserved DCD xPortPendSVHandler ; PendSV Handler, Q1 Y1 e! Q/ w8 f9 G$ A& `+ R: b DCD xPortSysTickHandler ; SysTick Handler 1 ?: E: O& F7 T: } 4.在main中建立自己任务开始 rtos $ u" j/ b+ ^4 C, Z /* Create one task. */# _, I3 J m; G+ j xTaskCreate( vTask1, /* Pointer to the function that implements the task. */' V1 L$ Q8 v: L9 h+ F "Task 1", /* Text name for the task. This is to facilitate debugging only. */: X# Z" O4 c& k/ H 200, /* Stack depth in words. */2 J! |( p$ ? _4 e+ [2 ?: {4 I- W NULL, /* We are not using the task parameter. */- ]3 Y9 M+ D" D: m( r2 c2 @& C 1, /* This task will run at priority 1. */ NULL ); /* We are not using the task handle. */# ^4 f [8 [- F7 c3 s' r : [7 X; G. C6 }; ~0 v2 u /* Create one task. */ xTaskCreate( vTask2, /* Pointer to the function that implements the task. */ "Task 2", /* Text name for the task. This is to facilitate debugging only. */4 x4 I1 l8 ]9 l# L 200, /* Stack depth in words. */ NULL, /* We are not using the task parameter. */. \+ U$ X# C5 f 2, /* This task will run at priority 1. */% Q1 p# o- C0 G U" W$ ]3 B- V NULL ); /* We are not using the task handle. */' w& N& r) ~( T0 e " P H, Q/ x- D9 G) j% ~ /* Start the scheduler so our tasks start executing. */* {- C( I# {& [, e3 q1 ~4 W5 a! x vTaskStartScheduler(); .............. ..............& [% ^+ }# I# J4 `* y& Z6 a" Z4 p 8 ~1 h1 K! [! W+ [5 S) ^) @* S void vTask1( void *pvParameters )6 Q1 \9 A( v! k; e { /* As per most tasks, this task is implemented in an infinite loop. */ while(1) { LED_Toggle(0);1 z$ X, C6 ]4 p4 W7 e' a+ i LED_Toggle(2); vTaskDelay(800); } } " F5 y% @' U" t0 f. q0 S0 e void vTask2( void *pvParameters )4 F' j1 c* Z1 w { /* As per most tasks, this task is implemented in an infinite loop. */5 q& J, O+ F6 k) y while(1)$ x$ ]1 H. }# T* M6 } { LED_Toggle(1); LED_Toggle(3); vTaskDelay(1600); }- C8 M+ [, c- l" L8 {3 y% ~ } |