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; |
//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 ); |
| } |