请教:SysTick与TIM做RTOS的timebase,孰优孰劣?

2019-12-11 18:38发布

最近做新项目更新了一下STM32CubeMX到4.16.1,执行生成代码时提示:
WARNINGS:
- When FreeRTOS is used, it is strongly recommanded to use HAL timebase source other than the Systick.
然后按提示设置SYS部分的Timebase Source,除了SysTick可选的就是各个未占用的TIM。
按我之前的理解,SysTick就是为了RTOS准备的专用定时器,这会CubeMX让我选普通的TIM,有点晕了,不知道为什么。
SysTick与TIM做RTOS的timebase,孰优孰劣?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
8条回答
iskywolf
1楼-- · 2019-12-11 22:57
找到原因了,完整的见:https://my.st.com/public/STe2eco ... mp;currentviews=502

摘一部分:
As mentioned is the UM1718 “STM32CubeM user manual:

“ By default, the STM32Cube HAL is built around a unique timebase source which is the ARM-Cortex system timer (SysTick).
However, HAL-timebase related functions are defined as weak so that they can be overloaded to use another hardware timebase source. This is strongly recommended when the application uses an RTOS, since this middleware has full control on the SysTick configuration (tick and priority) and most RTOSs force the SysTick priority to be the lowest.
Using the SysTick remains acceptable if the application respects the HAL programming model, that is, does not perform any call to HAL timebase services within an Interrupt Service Request context (no dead lock issue).
To change the HAL timebase source, go to the SYS peripheral in the IP tree pane and select a clock among the available clock sources: SysTick, TIM1, TIM2,...”

反正我TIM这块也不依赖HAL库,用systick无妨。
aozima
2楼-- · 2019-12-12 03:31
没区别

只是,既然已经有个专业的了,为何还要去挤其它功能。
Doding
3楼-- · 2019-12-12 07:08
中断优先级
overheat
4楼-- · 2019-12-12 07:58
iskywolf 发表于 2016-10-14 11:02
找到原因了,完整的见:https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFo ...

没太理解原因。。。。
给讲一下?
g921002
5楼-- · 2019-12-12 13:04
 精彩回答 2  元偷偷看……
qwe2231695
6楼-- · 2019-12-12 13:52
应该是当用了RTOS,就要设置HAL的timebase为其他Timer,因为Systick会被操作系统设置为最低优先级中断,以及HAL使用了weak定义timebase的ISR中断函数,大家用同一个,会被RTOS的版本重载。

一周热门 更多>