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

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

[复制链接]
52mcu 发布时间:2014-4-21 21:16
【STM32F429心得\疑问】+最新FreeRtos(版本8.0)上手指南
% k1 P- a, {. I5 r+ q8 V. @: |最近折腾一块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
$ E0 T( _' C1 ` ! H2 n9 g& j3 [( `  P  V) M
3,修改启动代码(.s文件)如下,主要是链接FreeRTOS的三个中断函数" r8 C0 G' n8 @' _  @3 P9 y
   l* D6 |- |! \$ u3 K
                                IMPORT xPortPendSVHandler
; k3 ?3 p  V' G, L5 |; H" d( c+ l                                IMPORT xPortSysTickHandler1 c+ t9 q9 k6 f2 P7 N; e7 k: o
                                IMPORT vPortSVCHandler
1 O6 D2 y5 R- l% c! H6 G                                .....
! }8 n# v0 R9 s                                DCD     vPortSVCHandler           ; SVCall Handler
. H( p1 t; N; P9 O1 X* }" |8 _        DCD     DebugMon_Handler          ; Debug Monitor Handler
# |+ ~: X( I& n  I$ V        DCD     0                         ; Reserved
  R& J8 J# ]+ @        DCD     xPortPendSVHandler        ; PendSV Handler, Q1 Y1 e! Q/ w8 f9 G$ A& `+ R: b
        DCD     xPortSysTickHandler       ; SysTick Handler                        1 ?: E: O& F7 T: }
                               
* l1 i9 P, ?/ h  q* i/ m4.在main中建立自己任务开始 rtos
$ E. e. G6 q5 {4 j/ H $ 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. */
9 D! u' d9 h, f3 r                    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. */
/ p# ?5 \8 S/ a: ?! U) L' _0 H    xTaskCreate(    vTask2,     /* Pointer to the function that implements the task. */
$ d2 g4 f+ {" J) ]$ Z) X                    "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. */
# z, j) D* V2 _- p4 U3 W                    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();
! {. W5 {( b2 P2 b0 o$ S( P. M' `..............
$ c6 N' o4 w% c+ ~* ?..............& [% ^+ }# 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
{
' {$ |. l( R% U" Z- J8 @5 B/ Z/ y    /* As per most tasks, this task is implemented in an infinite loop. */
* Z! V/ V# r3 w; x3 M    while(1)
/ }1 q0 R/ C5 e6 g8 Z    {
2 b- J; C% V* r9 q* i9 x7 j        LED_Toggle(0);1 z$ X, C6 ]4 p4 W7 e' a+ i
                LED_Toggle(2);
. v: I, A+ @- }3 y8 I        vTaskDelay(800);
1 k; w3 t9 X  R; D5 u  g. W# t    }
+ F$ S7 @! g! Q# [* ~- Q}
2 {  U/ d6 B/ r% R " F5 y% @' U" t0 f. q0 S0 e
void vTask2( void *pvParameters )4 F' j1 c* Z1 w
{
( D6 t. q" ~. I/ c$ x1 P    /* 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 }
    {
6 O7 m+ z1 d7 i, a( ^. P2 Q8 S. }        LED_Toggle(1);
# l, F9 R9 o1 ]  s                LED_Toggle(3);
* W. M$ B$ j  z$ I: j( w9 Y5 G- s        vTaskDelay(1600);
: k8 G! ]/ N" F0 }% `* L    }- C8 M+ [, c- l" L8 {3 y% ~
}
收藏 1 评论0 发布时间:2014-4-21 21:16

举报

0个回答
关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版