Tick time?

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

Tick time?

Jump to solution
1,561 Views
billnd
Contributor IV

Does _time_diff_xxx() have issues? I get some strange results when .TICKS in the start_tick_ptr is greater than the end_tick_ptr.

I'm trying to measure time between two points, //start time and //end time, then I calc the time with _time_diff_microseconds() at //calc time in the snippet below.

Output is shown below, everything seems OK till the line that starts with "50", then things seem a little strange to me!!

Anyone offer any insight?

Cheers,

Bill

The output...

time_us, tick_start.TICKS[0], tick_start.HW_TICKS, tick_end.TICKS[0], tick_end.HW_TICKS, overflowed

43,                                 21,                      162228,                       21,                    164286,            0

43,                                 21,                      187476,                       21,                    189534,            0

43,                                 21,                      212720,                       21,                    214778,            0

50,                                 21,                      238011,                       22,                          429,            0

43,                               222,                         1645,                      222,                        3703,            0

43,                               222,                        25923,                     222,                       27981,            0

43,                               222,                        51163,                     222,                       53221,            0


The code...

MQX_TICK_STRUCT tick_start, tick_end;
boolean overflowed;
uint_32 time_us, loop;

while( TRUE ){

//start time

    _time_get_ticks( &tick_start );
    for( loop = 0; loop < 300; ++loop ){
    }

//end time

    _time_get_ticks( &tick_end );

//calc time

    time_us = _time_diff_microseconds( &tick_end, &tick_start, &overflowed );
    printf( "\r\n%d,  %d, %d,  %d, %d,  %d", time_us, tick_start.TICKS[0], tick_start.HW_TICKS, tick_end.TICKS[0], tick_end.HW_TICKS, overflowed );
}
Tags (3)
0 Kudos
1 Solution
945 Views
billnd
Contributor IV

Apology time. Really sorry, I've finally opened my eyes to the obvious and realised this is all a big mistake on my part.

The increased time indicated in my original post, where there is a 50 instead of a 43 is caused by the sys tick timer interrupt occurring. Hence the roll over in HW_TICKS value. Blatantly obvious really, but sometime you just can't see the wood for the trees.

Sorry once again, and thanks for your help.

BillND

View solution in original post

0 Kudos
8 Replies
945 Views
DavidS
NXP Employee
NXP Employee

Hi billnd,

I'm not seeing that problem.

I'm running your code in MQX4.0 with CW10.3 on TWR-K60n512 Tower kit.

Couple things to try:

- clean and re-compile your RTOS then application

- if that doesn't help, then increase your stack size.  printf() can be piggy with the stack.

Hope this helps.

Regards,

David

945 Views
billnd
Contributor IV

Hi David,

Thanks for the reply.

I've rebuild the whole system, and increased the stack all with no joy. I'll continue digging.

I'm running with MQX4.0, IAR 6.5.3 on an MK10DN512VLL10 custom board.

BillND

0 Kudos
945 Views
DavidS
NXP Employee
NXP Employee

Hi BillND,

Don't bang the forehead too much ;-)

I just ran my code with IAR6.5.3 and have similar issue:

ScreenHunter_16 Mar. 29 17.48.gif

I will dig into this Monday....off for weekend.

Regards,

David

0 Kudos
945 Views
billnd
Contributor IV

Could this issue be related to this fix, due in 4.0.1?

Re: MQX 3.8 _time_get() -&gt;_time_to_date defect

0 Kudos
945 Views
DavidS
NXP Employee
NXP Employee

Hi Bill,

I sent my results to the factory for anaylsis.  That is in the queue.

But playing with this messed up my ability to repeat it.

I had used IAR6.5+JLink and saw the issue on TWR-K60N512 (Rev 1.x silicon) using MQX4.0.

I then use IAR6.4+JLink and didn't see the issue while using TWR-K60N512 and MQX4.0.

When I went back to using IAR6.5+JLink to re-test...the JLink will no longer work on the TWR-K60N512 :-( .

I do know that IAR6.5 has the updated flash configuration files for TWR-K60D100M (Rev 2.0 of K60 silicon).

I'm now speculating that is it an issue with the flash drivers that is preventing me from repeating the issue and I'll keep poking the factory to see if they can resolve/validate.

Summary: I don't think it is MQX issue (famous last words I know!).

Regards,

David

0 Kudos
946 Views
billnd
Contributor IV

Apology time. Really sorry, I've finally opened my eyes to the obvious and realised this is all a big mistake on my part.

The increased time indicated in my original post, where there is a 50 instead of a 43 is caused by the sys tick timer interrupt occurring. Hence the roll over in HW_TICKS value. Blatantly obvious really, but sometime you just can't see the wood for the trees.

Sorry once again, and thanks for your help.

BillND

0 Kudos
945 Views
billnd
Contributor IV

Nice one, cheers for the update.

0 Kudos
945 Views
billnd
Contributor IV

Hi David,

Did you make any progress with this?

Cheers,

Bill

0 Kudos