Page 1 of 1

How to get shorter time tick for OSTimeDly()

Posted: Tue Mar 10, 2020 8:13 pm
by leetehui
platform: MOD5270B
I need faster response of the module to the request. Currently, TICKS_PER_SECOND is 20. Every tick will takes 50 msec which is too slow for me.
I try to use OSChangeTaskDly() to change the new tick but it seems not working and the function is not recommended as described in the manual.
I try to change the define of TICKS_PER_SECOND to 200 in \include\constants.h and recompile the system file. The behavior of the module becomes a little queer. It becomes faster but I can't get the correct timing of the task for other purposes.
Any suggestion?

Re: How to get shorter time tick for OSTimeDly()

Posted: Wed Mar 11, 2020 3:37 pm
by pbreed
Are you trying to:
change the resolution of OS Timedly,
trying to increase the task switching speed.
trying to make more precise time measurments?

Do you need this for a single task/chunk of code, or many...


The call OSChangeTaskDly just changes the current delay interval for a specific task, it has nothing to do with ticks per second.

If you change TICKS_PER_SECOND you must rebuild EVERYTHING... system, platform and application ie rebuild everything.

Increasing TICKS_PERSECOND will increase the resolution of OSTimeDly and all pend/post timeouts.
It will have ZERO effect on the task switching speed as that has no releation to ticks...
The highest priority unblocked task always runs, and the task switching latency on 5270 is on the order of 1 to 2 uSec.

You can get high precision delays using the high res timer class....

What NNDK version are you running?

#include <HiResTimer.h>

Re: How to get shorter time tick for OSTimeDly()

Posted: Wed Mar 11, 2020 3:41 pm
by pbreed
Are you trying to:
change the resolution of OS Timedly,
trying to increase the task switching speed.
trying to make more precise time measurments?

Do you need this for a single task/chunk of code, or many...


The call OSChangeTaskDly just changes the current delay interval for a specific task, it has nothing to do with ticks per second.

If you change TICKS_PER_SECOND you must rebuild EVERYTHING... system, platform and application ie rebuild everything.

Increasing TICKS_PERSECOND will increase the resolution of OSTimeDly and all pend/post timeouts.
It will have ZERO effect on the task switching speed as that has no releation to ticks...
The highest priority unblocked task always runs, and the task switching latency on 5270 is on the order of 1 to 2 uSec.

You can get high precision delays using the high res timer class....

What NNDK version are you running?

#include <HiResTimer.h>

//Should either be global static or only constructed ONCE...
HiResTimer MyTimer( DEFAULT_TIMER);


Then
MyTimer .delay_uSec(delay_in_usec); //Use to block and task swithc should not be used for delays shortere than 150usec...

or...

MyTimer.pollingDelay_uSec(delay_in_usec); //Can be used for very short delays, this is a spin loop so task still runs... does not block or allow other tasks to run.

Re: How to get shorter time tick for OSTimeDly()

Posted: Tue Apr 14, 2020 7:22 pm
by leetehui
Thank you very much for your reply. Sorry for the late response. I am shifted to other tasks recently.
I am using NNDKSetupRel24_rc2.exe for MOD5070B. Quite an old version I believe.
I need a faster response of certain task in my program. No problem with task switch.
HiResTimer seems to be a good solution. I think I need to update my NNDK.
I will do more trials and post my test results later.

Re: How to get shorter time tick for OSTimeDly()

Posted: Thu Apr 16, 2020 7:06 am
by pbreed
The task switch is in usec.
If you are having task performance issues, its probably because some higher priority task is running.

The Tick interval ONLY effects the timeout, not the task switch time.