c - 在 UC/OS-II 中打印 OSTime
问题描述
设备:F28335 contorolCRAD 和实验者套件 - Delfino F28335。
移植 ucos-II。
我使用 OSTimeGet() 函数来获取 OSTime。
但是 task1 每次都返回 '0' 并且 task2 不起作用。
问题是什么?如何解决这个问题?
App_Task1's priority = 6u
App_Task2's priority = 7u
static void App_Task1 (void *p_arg)
{
(void)&p_arg;
INT32U t;
while (DEF_TRUE) {
t = OSTimeGet();
printf("Task1 \n");
printf("OSTime=%lu\n",t);
OSTimeDly(5);
}
}
static void App_Task2 (void *p_arg)
{
(void)&p_arg;
INT32U t;
while (DEF_TRUE) {
t = OSTimeGet();
printf("Task2 \n");
printf("OSTime=%lu\n",t);
OSTimeDly(10);
}
}
output
Task1 OSTime=0
解决方案
您的 Systick 功能似乎运行不正确。由于我对您使用的芯片没有经验,因此无法给您完整的答案。但是你的 systick 函数应该包含这样的东西。这是来自 LPC17xx 的代码,但你应该会发生类似的事情
void OS_CPU_SysTickHandler (void)
{
CPU_SR_ALLOC();
CPU_CRITICAL_ENTER();
OSIntNestingCtr++; /* Tell uC/OS-II that we are starting an ISR */
CPU_CRITICAL_EXIT();
OSTimeTick(); /* Call uC/OS-II's OSTimeTick() */
OSIntExit(); /* Tell uC/OS-II that we are leaving the ISR */
}
OSTimeTick() 用于您的 OSTimeDly()、OSTimeGet() 和任务切换
推荐阅读
- flutter - 如何在 Flutter 应用程序中翻译字符串中的特殊字符?示例:“Déjà Vu”到“Déjà Vu”
- java - 我使用哪个对象?
- python-3.x - 如何从 Pandas DataFrame 中绘制家谱?
- jenkins-pipeline - Jenkinsfile:带有包依赖的monorepo
- node.js - Socket.io 将文件写入用户磁盘
- python - 在 Python 中使用 Key 打印 JSON 数据
- css - 我希望引导程序在手机屏幕减小并随后在下一行推送其他标签时仅显示一个标签和输入字段
- java - 如何从 OpenXava 中的操作(在运行时以编程方式)更改属性的标签?
- reactjs - react app 如何在 antd 表中设置单选按钮的状态?
- webpack - Webpack 4 外部,意外令牌,加载外部库