Time_Delay tick duration error

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Time_Delay tick duration error

跳至解决方案
997 次查看
davidzhou
Contributor V

Hi,

I have K60 Tower board: _K60P144M150SF3RM. CodeWarrior Version 10.6.4. MQX 4.2

I found that the system timer tick has a big deviation. For example:

In a task with priority 4 as highest in the project. In the task, just loop a counter with _time_delay(10):

void CAN_Task(uint32_t initial_data) {
volatile int iCanTaskCount = 0;   
while (1) {
_time_delay(10);     //it seems that one cylce = 14.93 ms time, or 1 tick = 1.493 ms
iTaskCount++;
PRINT_MSG("%x: %d\r\n", iTaskCount);
}

//RESULT:

FOR 60SECONDS time duration, iTaskCount= 4018.

If the timer is accurrate, then the output of the iTaskCount shall be 6000.

That is huge error. Is it a software issue, or the system oscillator has error? 

Thank you,

David Zhou

0 项奖励
回复
1 解答
878 次查看
danielchen
NXP TechSupport
NXP TechSupport

Hi David:

_time_delay() is blocking function, which puts the calling task to the timeout queue. When timeout exceeds for the task ( measured by the BSP tick timer interrupt ) the task is put back to ready queue. Then , RTOS scheduler runs and selects next active task to run depending on scheduling rules.

It depends on what are other ready tasks at the moment and their priorities and what interrupts are running at the moment. _time_delay() is specified to guarantee minimum time, not maximum. Maximum depends on the application. That is normal RTOS behavior.

So, what you mentioned is a normal hehaviour.

Have a nice weekend!

Regards

Daniel

在原帖中查看解决方案

0 项奖励
回复
1 回复
879 次查看
danielchen
NXP TechSupport
NXP TechSupport

Hi David:

_time_delay() is blocking function, which puts the calling task to the timeout queue. When timeout exceeds for the task ( measured by the BSP tick timer interrupt ) the task is put back to ready queue. Then , RTOS scheduler runs and selects next active task to run depending on scheduling rules.

It depends on what are other ready tasks at the moment and their priorities and what interrupts are running at the moment. _time_delay() is specified to guarantee minimum time, not maximum. Maximum depends on the application. That is normal RTOS behavior.

So, what you mentioned is a normal hehaviour.

Have a nice weekend!

Regards

Daniel

0 项奖励
回复