11.07.2015 Views

IAR PowerPac RTOS User Guide

IAR PowerPac RTOS User Guide

IAR PowerPac RTOS User Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Time measurementPrototypeU32 OS_GetTime32 (void);Return valueThe system variable OS_Time as a 32-bit integer value.Additional InformationThis function always returns the system time as a 32-bit value. Because the OS_Time variable is also a 32-bit value, thereturn value is simply the entire contents of the OS_Time variable.High-resolution measurementHigh-resolution measurement allows for fine-tuning of time measurement. While system resolution depends on theCPU used, it is typically about 1 µs, making high-resolution measurement about 1000 times more accurate than lowresolutioncalculations.Instead of measuring the number of completed ticks at a given time, an internal count is kept of the number of cyclesthat have been completed. Look at the illustration below, which measures the execution time of the same code used inthe low-resolution calculation. For this example, we assume that the CPU has a timer running at 10 MHz and is countingup. The number of cycles per tick is therefore (10 MHz / 1 kHz) = 10,000. This means that with each tick-interrupt, thetimer restarts at 0 and counts up to 10,000.OS_GetTime() => 0 OS_GetTime() => 5Code to be timedOS_Time0.5 ms 5.2 ms0 ms 1 ms 2 ms 3 ms 4 ms 5 ms6 msThe call to OS_Timing_Start() calculates the starting value at 5,000 cycles, while the call to OS_Timing_End()calculates the ending value at 52,000 cycles (both values are kept track of internally). The measured execution time ofthe code in this example would therefore be (52,000 - 5,000) = 47,000 cycles, which corresponds to 4.7 ms.Although the function OS_Timing_GetCycles() may be used for returning the execution time in cycles as above, itis typically more common to use the function OS_Timing_Getus(), which returns the value in microseconds (µs). Inthe above example, the return value would be 4,700 µs.Data structureAll high-resolution routines take as parameter a pointer to a data structure of type OS_TIMING, defined as follows:#define OS_TIMING OS_U32PP<strong>RTOS</strong>-2115

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!