FreeRTOS 配置TICK_RATE_HZ

发布于 2024-08-21 10:03:08 字数 980 浏览 2 评论 0原文

我使用的是带有 5.4 版 FreeRTOS 的 MSP430f5438。

我有一个有趣的问题,我无法弄清楚。

基本上,当我将 configTICK_RATE_HZ 设置为不同的值时,LED 闪烁得更快或更慢;它应该保持相同的速率。我将 configTICK_RATE_HZ 设置得越高,它闪烁得越慢,而当我将 TICK_RATE 设置得较低时,它闪烁得越快。

vTaskDelayUntil( &xLastFlashTime, xFlashRate );无论 configTICK_RATE_HZ 是多少,LED 应该每秒只闪烁一次。我逐步检查了 xFlashRate 以进行确定。它总是 = configTICK_RATE_HZ。 代码:

xFlashRate = ledFLASH_RATE_BASE;//my flash base rate is 1000ms
xFlashRate /= portTICK_RATE_MS; //so xFlashrate = whatever configTICK_RATE_HZ equals

/* We need to initialise xLastFlashTime prior to the first call to vTaskDelayUntil().*/ 
xLastFlashTime = xTaskGetTickCount();
for(;;) { 
vTaskDelayUntil( &xLastFlashTime, xFlashRate ); vParTestToggleLED( uxLED ); 
flashled();//this should happen every 1 second.
}

当我将 configtick_rate_hz 设置为 1000 时,LED 闪烁的周期大于 1 秒,而当我将节拍率设置为小于 ~200

configTICK_RATE_HZ 时,LED 闪烁的周期远小于 1 秒,不应影响 LED 闪烁时间。

我意识到需要更多信息,并将随时提供所需的任何代码片段来提供帮助。

I am using an MSP430f5438 with version 5.4 of FreeRTOS.

I am having a funny problem that I can't figure out.

Basically, when I set configTICK_RATE_HZ to different values, the LED blinks faster or slower; it should stay the same rate. It blinks slower the higher i set configTICK_RATE_HZ, and faster when I set TICK_RATE lower.

vTaskDelayUntil( &xLastFlashTime, xFlashRate ); is such that the LED should only blink once a second no matter what the configTICK_RATE_HZ is. I stepped through and checked the xFlashRate to make sure. Its always = to the configTICK_RATE_HZ.
Code:

xFlashRate = ledFLASH_RATE_BASE;//my flash base rate is 1000ms
xFlashRate /= portTICK_RATE_MS; //so xFlashrate = whatever configTICK_RATE_HZ equals

/* We need to initialise xLastFlashTime prior to the first call to vTaskDelayUntil().*/ 
xLastFlashTime = xTaskGetTickCount();
for(;;) { 
vTaskDelayUntil( &xLastFlashTime, xFlashRate ); vParTestToggleLED( uxLED ); 
flashled();//this should happen every 1 second.
}

The led blink with a period greater than 1 second when i set the configtick_rate_hz to 1000 and the led blinks with a period far less than 1s when i set the tick rate to anything less than ~200

configTICK_RATE_HZ should not affect the LED blinktime.

I realize more info is needed and will readily supply whatever code snippets are needed to help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

隐诗 2024-08-28 10:03:08

RTOS 节拍由定时器中断生成。计时器设置(不正确),因此无论您设置 configTICK_RATE_HZ 是什么,它总是会在 400kHz 处产生固定滴答声。由于闪烁率是在 RTOS 滴答率由 configTICK_RATE_HZ (portTICK_RATE_MS = 1000/configTICK_RATE_HZ) 正确表示的假设下设置的,因此问题随之而来。

The RTOS tick is generated by a Timer interrupt. The timer was set (improperly) such that it always caused a fixed tick at 400kHz no matter what you set configTICK_RATE_HZ too. Since the blink rate is set under the assumption that the RTOS tick rate is properly represented by the configTICK_RATE_HZ (portTICK_RATE_MS = 1000/configTICK_RATE_HZ), problems ensued.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文