你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

【STM32F429心得\疑问】+最新FreeRtos(版本8.0)上手指南

[复制链接]
52mcu 发布时间:2014-4-21 21:16
【STM32F429心得\疑问】+最新FreeRtos(版本8.0)上手指南
- H4 J/ k' z. a7 C. {0 \最近折腾一块stm32f107rc的板子,摸索了一下FreeRTOS 的使用
, P+ p# _6 U# V6 J" W7 n3 `: v: g" u发现起步不太难有点经验和大家分享。) s4 h6 P$ U9 c. j7 ~
1,先从官网http://www.freertos.org/下载 FreeRTOS 8.0.0 ! f/ G! T- g  j8 W7 W% D, V' C
2,用标准库(STM32F10x_StdPeriph_Lib_V3.5.0)模板建工程/ D2 `, o# x3 g
3, 在工程中添加FreeRTOS 文件。tasks.c  list.c queue.c heap_2.c$ `. q0 t2 l9 u& K8 [* u+ f
   port.c  其中port.C是cotex M3的移植文件。选择目录..\..\Source\portable\RVDS\ARM_CM3\
: f" J3 @( {! j3 }; S1 C   下的port.c
7 N- ~$ ]/ K+ S4 A% ~5 Y, |. _ 
0 R  P- h* ]" k3,修改启动代码(.s文件)如下,主要是链接FreeRTOS的三个中断函数
+ r& s/ t) U) B) E% l / K* c- h/ r, B
                                IMPORT xPortPendSVHandler
5 T  Z9 f+ k' _( f! i; g/ o: e                                IMPORT xPortSysTickHandler
( `% ~1 ]9 P/ o& Z" d/ I9 m                                IMPORT vPortSVCHandler3 ?6 y6 D0 O9 j1 g4 m8 y
                                ....., m% V+ y: e) N4 \( t/ p
                                DCD     vPortSVCHandler           ; SVCall Handler7 P' Q4 y7 b6 J; P; B
        DCD     DebugMon_Handler          ; Debug Monitor Handler5 ^: x' H3 v; R: n2 g
        DCD     0                         ; Reserved
1 S3 d- v3 l' P( _        DCD     xPortPendSVHandler        ; PendSV Handler9 N7 ]! {* ?" o% K! l
        DCD     xPortSysTickHandler       ; SysTick Handler                        - ]2 a+ f& s$ R. l) E
                               
5 |, L% \6 `$ e4.在main中建立自己任务开始 rtos
; [  V+ d6 Y& r0 r4 d8 r, r* R 
7 Y. t+ S% K, @0 e  /* Create one task. */. l; h+ V. p0 s4 O4 A8 T3 Y" e
    xTaskCreate(    vTask1,     /* Pointer to the function that implements the task. */
" B7 \2 V9 C# X* F# Y7 o" W& q                    "Task 1",   /* Text name for the task.  This is to facilitate debugging only. */5 o# `. W) Y& R/ Q; n( o2 _5 d
                    200,        /* Stack depth in words. */9 U; Q& f! C4 l, ]0 `
                    NULL,       /* We are not using the task parameter. */
4 o) V# z' B0 X0 i4 D- g$ o                    1,          /* This task will run at priority 1. */% n; Y- l1 o  i! `! F! Q2 _
                    NULL );     /* We are not using the task handle. */- r6 W, n7 D' z
   H6 B; y. J: [* ~& a* P0 w+ f
    /* Create one task. */" B7 y* P+ Q' b8 r
    xTaskCreate(    vTask2,     /* Pointer to the function that implements the task. */
" ^% k2 o5 m5 e4 W! s, R                    "Task 2",   /* Text name for the task.  This is to facilitate debugging only. */
9 l' D5 N4 U7 r% w                    200,        /* Stack depth in words. */
4 p" ?' Z' H5 ~                    NULL,       /* We are not using the task parameter. */
. K6 H; W0 d# _8 u9 A' r                    2,          /* This task will run at priority 1. */
8 w  ?1 U- G. g, `) b; h' ^  i3 C                    NULL );     /* We are not using the task handle. */
2 M8 @8 K5 Y& A$ h: u. Y 
0 _% {" v" f$ W7 X7 T1 P4 k, e4 H    /* Start the scheduler so our tasks start executing. */
- _* @; e0 ^4 ~    vTaskStartScheduler();
, `" R3 J, c6 \& g8 U; w, S) y5 o..............
2 {- [- t( x( H3 n..............- {) Z/ G0 f0 w7 d2 R1 I
 8 b6 O$ p+ G# g# [7 Q% g2 ?
void vTask1( void *pvParameters )
5 ^: C* c, }. j9 ~" B{- p5 z* f) }. j' F0 n+ h# m
    /* As per most tasks, this task is implemented in an infinite loop. */6 U8 o! A$ d; n, b
    while(1)2 j) g/ C1 x; G4 l. n* h' A
    {
* ~% Q, i+ D. U1 V" H        LED_Toggle(0);
# o& x0 ?/ n) D" d$ P" F                LED_Toggle(2);
% d( n: c9 c2 N! N: n( T, T7 q" @7 D        vTaskDelay(800);. y. c: \! O* i& X" e8 G$ ?
    }- ?4 Z% g3 |. \( w( t% p
}
: r# `* s! Q8 n9 { 
& P* Q6 L3 L6 H2 Y3 s9 R3 d: ~void vTask2( void *pvParameters )2 T  o4 |! O) K. E& L# j- |. [3 H
{4 ~6 L- C! \% U7 _9 q
    /* As per most tasks, this task is implemented in an infinite loop. */; t# R& r$ }1 f0 S8 V* y
    while(1)
' T( X: Q# K, N3 t# I    {
' B7 {0 Y) K/ ~: ?# ?6 X        LED_Toggle(1);
5 R' ]0 M! A3 E3 @7 C( H9 G                LED_Toggle(3);/ a! Z/ Y9 u6 ?2 m- J  Z
        vTaskDelay(1600);
) [  o- R" Z, l) F. v. f- C    }" M1 h% q  Y$ L& ~9 L0 c
}
赞 收藏 1 评论0 发布时间:2014-4-21 21:16

举报

0个回答

所属标签

相似技术帖

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版