有用FreeRTOS的朋友吗,怎样精确定时(10ms)调用一个task呢?

tamyix 2010-05-04 09:19:33
我用了vTaskDelay,好像不行啊
...全文
541 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tsy040501 2012-08-26
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
vTaskDelay很难实现的,不过有个vTaskDelayUntill可以满足。如下面的例子:

static void vTempTask(void* pvParameters)
{
uint8_t msb;
uint16_t samplecount = 0;
uint16_t xLastWakeTime = xTaskGetTick……
[/Quote]

你调用的延迟函数,使该任务进入阻塞状态,处理器有没有做必要的处理?在恢复之后,处理器有没有对这个任务的堆栈进行存储保护,比如push等等的???
tamyix 2010-05-04
  • 打赏
  • 举报
回复
搞定了,谢谢。
thinkli 2010-05-04
  • 打赏
  • 举报
回复
vTaskDelay很难实现的,不过有个vTaskDelayUntill可以满足。如下面的例子:

static void vTempTask(void* pvParameters)
{
uint8_t msb;
uint16_t samplecount = 0;
uint16_t xLastWakeTime = xTaskGetTickCount();
/* The display period is 1000 ticks, about 1s */
const uint16_t xWakePeriod = 1000;
/* Initialize the uart port, and the temperature sensor */
uart0_init(UART0_CONFIG_1MHZ_115200);
ds1722_init();
ds1722_set_res(8);
ds1722_sample_cont();
/* Infinite loop */
while(1)
{
/* Read the sensor and increment the sample count */
msb = ds1722_read_MSB();
samplecount++;
/* Print the result on the uart port */
printf("Sample #%u: temperature = %u C\r\n", samplecount, msb);
/* Block until xWakePeriod ticks since previous call */
vTaskDelayUntil(&xLastWakeTime, xWakePeriod);
}
}

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧