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

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

[复制链接]
52mcu 发布时间:2014-4-21 21:16
【STM32F429心得\疑问】+最新FreeRtos(版本8.0)上手指南# x- \3 G& U* ?$ I) Z9 h. b
最近折腾一块stm32f107rc的板子,摸索了一下FreeRTOS 的使用
2 Z( K3 J' ?) M发现起步不太难有点经验和大家分享。
# _/ p) w$ W3 w# w$ G$ X: R1,先从官网http://www.freertos.org/下载 FreeRTOS 8.0.0 
( i: E$ M+ j) d) a1 k) B2 s2,用标准库(STM32F10x_StdPeriph_Lib_V3.5.0)模板建工程( P6 E- [. B0 Q' W" f$ X
3, 在工程中添加FreeRTOS 文件。tasks.c  list.c queue.c heap_2.c
) K5 \) ]" M# }$ }, B   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
& I% N3 V( O. m$ B+ I3 j9 P                                IMPORT xPortSysTickHandler# M2 H* ~7 }8 v5 \# {# u" b
                                IMPORT vPortSVCHandler/ j* s6 q  s2 c$ N
                                .....
3 f  U7 R9 V8 N: v                                DCD     vPortSVCHandler           ; SVCall Handler
! Q, W- l1 S# T* u        DCD     DebugMon_Handler          ; Debug Monitor Handler
" r9 ?) g& |& j; C6 T        DCD     0                         ; Reserved6 m- S0 n& v0 B9 c
        DCD     xPortPendSVHandler        ; PendSV Handler3 P/ {, x! I3 j% Q& U8 n+ [) }
        DCD     xPortSysTickHandler       ; SysTick Handler                       
- R2 }2 r$ [$ o/ I2 ]                               
1 b* W: _9 ~8 p" ^( l4.在main中建立自己任务开始 rtos
+ x# a) Y% C1 S$ g; O( M 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. */
6 \6 V6 Y4 j6 e! \, Y0 n9 @                    "Task 1",   /* Text name for the task.  This is to facilitate debugging only. */
- H- G  P7 d) V: T5 E9 k                    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
 
7 X0 w: l# P% m    /* Create one task. */1 u/ U5 }  Z; z+ F' T! A. z
    xTaskCreate(    vTask2,     /* Pointer to the function that implements the task. */
: R$ i1 D) p. \                    "Task 2",   /* Text name for the task.  This is to facilitate debugging only. */( s6 [7 w( a, \
                    200,        /* Stack depth in words. */
7 ~2 c& X" j9 U( i. @6 U                    NULL,       /* We are not using the task parameter. */
! Z$ Q) T5 d3 V( a6 M3 U                    2,          /* This task will run at priority 1. */- Q! `/ _% Y! j. X6 ~3 ^( X: a
                    NULL );     /* We are not using the task handle. */
+ @, j* a  j; Y: V. U7 S  w 
% u& ^$ p" \+ n0 A+ R* @+ a    /* Start the scheduler so our tasks start executing. */
+ S3 `/ r4 S7 j; z- |. G    vTaskStartScheduler();
: C9 `- @' R/ C+ w0 X6 c..............! s0 b& M3 ?: q# D
..............
$ l0 b* P  z( f, c, ?1 B 
& t! ~1 {; H* P2 O: Y1 B0 |0 Evoid vTask1( void *pvParameters )
) m9 t, J$ _; k; z: |$ _{
! v5 C4 F( T6 v( |! N    /* As per most tasks, this task is implemented in an infinite loop. */7 x6 b( t# f" D, O2 u0 R
    while(1)
4 c  ]3 [* Z1 N- W    {
" s% t, l2 L! X' g( d8 b        LED_Toggle(0);
* D" f# b& n8 c+ H$ d                LED_Toggle(2);
* ^  d' S* G7 u3 P3 M: h        vTaskDelay(800);
2 w8 ~0 |" P" ]+ k# b& A    }
9 ?* P% s  E' m5 V9 `}
- G) I. `. s" G( z3 H$ c 
, p7 Y+ X3 R: c/ I* [void vTask2( void *pvParameters )
2 A0 ^1 ~% Y7 |{( Y: x; u. `8 q# P* y
    /* As per most tasks, this task is implemented in an infinite loop. */
$ K' l5 V7 r: C  }$ ]    while(1); \7 E8 X' ]0 J) f
    {
) S" e$ z: n8 N, Z& L5 r, A: g        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( |
}
赞 收藏 1 评论0 发布时间:2014-4-21 21:16

举报

0个回答

所属标签

相似技术帖

官网相关资源

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