野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 23562|回复: 8

FreeRTOS 软件定时器周期设置超过2小时,会提前进入定时器回调函数

[复制链接]
发表于 2019-6-11 11:03:06 | 显示全部楼层 |阅读模式
我通过官网下载的10.2.1和10.0.1版本移植在f405板子上。软件定时器设置周期为4小时,结果30分钟左右就进入定时器回调函数了。设置为1小时则时间准确。
有遇到相同的问题的么?

回复

使用道具 举报

发表于 2019-6-11 11:03:38 | 显示全部楼层
是否溢出反转了?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-6-11 11:24:57 | 显示全部楼层
aozima 发表于 2019-6-11 11:03
是否溢出反转了?

我用的是32位的tick,理论上可以设置成很多天。我只设置了4小时(1000*60*60*4)。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-6-12 13:25:39 | 显示全部楼层
aozima 发表于 2019-6-11 11:03
是否溢出反转了?

非常感谢,问题找到了,确实是溢出了:/* Converts a time in milliseconds to a time in ticks.  This macro can be
overridden by a macro of the same name defined in FreeRTOSConfig.h in case the
definition here is not suitable for your application. */
#ifndef pdMS_TO_TICKS
        #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) )
#endif
这里溢出了。
https://sourceforge.net/p/freertos/bugs/135/
https://www.freertos.org/FreeRTO ... tion_317c7160j.html
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-6-12 13:27:11 | 显示全部楼层
感谢,问题找到了:/* Converts a time in milliseconds to a time in ticks.  This macro can be
overridden by a macro of the same name defined in FreeRTOSConfig.h in case the
definition here is not suitable for your application. */
#ifndef pdMS_TO_TICKS
        #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) )
#endif
这里溢出了。
https://sourceforge.net/p/freertos/bugs/135/
https://www.freertos.org/FreeRTO ... tion_317c7160j.html
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-6-12 16:35:49 | 显示全部楼层
google 发表于 2019-6-11 11:24
我用的是32位的tick,理论上可以设置成很多天。我只设置了4小时(1000*60*60*4)。

感谢你,确实溢出了:/* Converts a time in milliseconds to a time in ticks.  This macro can be
overridden by a macro of the same name defined in FreeRTOSConfig.h in case the
definition here is not suitable for your application. */
#ifndef pdMS_TO_TICKS
        #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) )
#endif
这里溢出了。
https://sourceforge.net/p/freertos/bugs/135/
https://www.freertos.org/FreeRTO ... tion_317c7160j.html
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-6-12 16:36:25 | 显示全部楼层
aozima 发表于 2019-6-11 11:03
是否溢出反转了?

感谢,确实是溢出了
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-6-12 16:37:17 | 显示全部楼层
这个宏 #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) )
会溢出
https://sourceforge.net/p/freertos/bugs/135/
https://www.freertos.org/FreeRTOS_Support_Forum_Archive/February_2016/freertos_On_pdMS_TO_TICKS_macro_definition_317c7160j.html
回复 支持 反对

使用道具 举报

发表于 2021-6-11 16:54:24 | 显示全部楼层
学习学习,学习学习。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-5-6 00:52 , Processed in 0.042349 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表