在线时间0 小时
UID395274
ST金币0
蝴蝶豆0
注册时间2012-10-16
新手上路
- 最后登录
- 1970-1-1
|
发表于 2012-10-24 18:09:37
|
显示全部楼层
a0a.1 0b0c
回复:ucOSii的延时时间和实际的不一样,慢了许多
OSTimeDly函数的参数并不是毫秒数哦,是ticks!!! 下面是它的定义:
void OSTimeDly (INT16U ticks)
{
INT8U y;
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr = 0;
#endif
if (OSIntNesting > 0) { /* See if trying to call from an ISR */
return;
}
if (ticks > 0) { /* 0 means no delay! */
OS_ENTER_CRITICAL();
y = OSTCBCur->OSTCBY; /* Delay current task */
OSRdyTbl[y] &= ~OSTCBCur->OSTCBBitX;
if (OSRdyTbl[y] == 0) {
OSRdyGrp &= ~OSTCBCur->OSTCBBitY;
}
OSTCBCur->OSTCBDly = ticks; /* Load ticks in TCB */
OS_EXIT_CRITICAL();
OS_Sched(); /* Find next task to run! */
}
} |
|