我测试了一下ucosII的软件定时器,
void MyCallback (OS_TMR *ptmr, void *p_arg)
{
gPM_MsgStartRouter(ECO_TRUE);
return;
}
void Test(void)
{
INT8U Per;
OS_TMR* Tmer1;
Tmer1=OSTmrCreate(20,20,OS_TMR_OPT_PERIODIC,(OS_TMR_CALLBACK)MyCallback,0,"Timer",&
er);
OSTmrStart(Tmer1,&
er);
}
debug发现
OSTmrCreate和OSTmrStart 中Per都为0,说明创建和启动都成功了,但
MyCallback 函数一直未执行。程序的线程并没有死,一直在跑着。不明白这是怎么回事?
---------------------------------
函数注释上是这样写的
* perr Is a pointer to an error code. '*perr' will contain one of the following:
* OS_ERR_NONE
* OS_ERR_TMR_INVALID_DLY you specified an invalid delay
* OS_ERR_TMR_INVALID_PERIOD you specified an invalid period
* OS_ERR_TMR_INVALID_OPT you specified an invalid option
* OS_ERR_TMR_ISR if the call was made from an ISR
* OS_ERR_TMR_NON_AVAIL if there are no free timers from the timer pool
* OS_ERR_TMR_NAME_TOO_LONG if the timer name is too long to fit
其中 OS_ERR_NONE为0。按注释说的使用Per应该是可以的吧?
一周热门 更多>