OsIf counter issue

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

OsIf counter issue

465 Views
zp001
Contributor III

Hello NXP team,

static void my_task(void *para)
{
	(void)para;
	static uint32_t cur_time = 0;
	static uint32_t prev_time = 0;
	static uint32_t cur_tick = 0;
	static uint32_t prev_tick = 0;
	static uint32_t start_time = 0;
	static uint32_t elapsed_time = 0;

	while(1)
	{
		start_time = OsIf_GetCounter(OSIF_COUNTER_SYSTEM);
		printf("start_time  %ld\r\n", start_time);
		vTaskDelayUntil( &xLastWakeTime, 100/ portTICK_PERIOD_MS);
		elapsed_time = OsIf_GetElapsed(&start_time, OSIF_COUNTER_SYSTEM);
		printf("elapsed_time  %ld deta time = %ld\r\n", elapsed_time, elapsed_time - start_time);
		prev_time = cur_time;
		cur_time = OsIf_GetCounter(OSIF_COUNTER_SYSTEM);
		printf("current time %ld prev_time %ld cur_tick %ld prev_tick %ld \r\n", cur_time, prev_time, cur_tick, prev_tick);
		printf("current time %ld\r\n", cur_time);
	}
}

my_task is scheduled about every 100ms,the question is the values of cur_time and elapsed time are not regular.

I'd like to know how to get system tick.

0 Kudos
1 Reply

444 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @zp001 

You mentioned that the values of cur_time and elapsed time are not regular, is there too much of a difference between each value? Could you share some values you got?
Also, may I know if you have more tasks?
Did you try any sample code? If the answer is yes, did you see any similar behavior?

One last thing, which MCU are you using?

It would be helpful if you could provide me with this information.

 

B.R.

VaneB

0 Kudos