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 measurementIntroduction<strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> supports 2 types of time measurement:● Low resolution (using a time variable)● High resolution (using a hardware timer)Both are explained in this chapter.<strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> supports two basic types of run-time measurement which may be used for calculating theexecution time of any section of user code. Low-resolution measurements use a time base of ticks, while highresolutionmeasurements are based on a time unit called a cycle. The length of a cycle depends on the timer clockfrequency.Low-resolution measurementThe system time variable OS_Time is measured in ticks, or ms. The low-resolution functions OS_GetTime() andOS_GetTime32() are used for returning the current contents of this variable. The basic idea behind low-resolutionmeasurement is quite simple: The system time is returned once before the section of code to be timed and once after,and the first value is subtracted from the second to obtain the time it took for the code to execute.The term low-resolution is used because the time values returned are measured in completed ticks. Consider thefollowing: with a normal tick of 1 ms, the variable OS_Time is incremented with every tick-interrupt, or once every ms.This means that the actual system time can potentially be more than what a low-resolution function will return (forexample, if an interrupt actually occurs at 1.4 ticks, the system will still have measured only 1 tick as having elapsed).The problem becomes even greater with runtime measurement, because the system time must be measured twice. Eachmeasurement can potentially be up to 1 tick less than the actual time, so the difference between two measurementscould theoretically be inaccurate by up to two ticks.PP<strong>RTOS</strong>-2 113

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

Saved successfully!

Ooh no, something went wrong!