Time_Delay tick duration error

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Time_Delay tick duration error

Jump to solution
429 Views
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 Kudos
1 Solution
310 Views
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

View solution in original post

0 Kudos
1 Reply
311 Views
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 Kudos