IAR PowerPac RTOS User Guide

IAR PowerPac RTOS User Guide IAR PowerPac RTOS User Guide

ie.ksu.edu.tw
from ie.ksu.edu.tw More from this publisher
11.07.2015 Views

High-resolution measurement API function overviewRoutineOS_TimingStart()OS_TimingEnd()OS_Timing_Getus()OS_Timing_GetCycles()OS_TimingStart()DescriptionMarks the beginning of a section of code to be timed.Prototypevoid OS_Timing_Start (OS_TIMING* pCycle);ParameterDescriptionAdditional InformationThis function must be used with OS_Timing_End().OS_TimingEnd()DescriptionMarks the end of a section of code to be timed.Prototypevoid OS_Timing_End (OS_TIMING* pCycle);ParameterDescriptionAdditional InformationThis function must be used with OS_Timing_Start().OS_Timing_Getus()DescriptionReturns the execution time of the code between OS_Timing_Start() and OS_Timing_End() in microseconds.PrototypeOS_U32 OS_Timing_Getus (OS_TIMING* pCycle);ParameterDescriptionAdditional InformationThe execution time in microseconds (µs) as a 32-bit integer value.OS_Timing_GetCycles()DescriptionDescriptionTable 119: High-resolution measurement API overviewpCycleTable 120: OS_TimingStart() parameter listpCycleTable 121: OS_TimingEnd() parameter listpCycleTable 122: OS_Timing_Getus() parameter listMarks the beginning of a code section to be timed.Marks the end of a code section to be timed.Returns the execution time of the code between OS_Timing_Start() andOS_Timing_End() in microseconds.Returns the execution time of the code between OS_Timing_Start() andOS_Timing_End() in cycles.Pointer to a data structure of type OS_TIMING.Pointer to a data structure of type OS_TIMING.Pointer to a data structure of type OS_TIMING.Returns the execution time of the code between OS_Timing_Start() and OS_Timing_End() in cycles.116IAR PowerPac RTOSfor ARM CoresPPRTOS-2

Time measurementPrototypeOS_U32 OS_Timing_GetCycles (OS_TIMING* pCycle);ParameterDescriptionpCyclePointer to a data structure of type OS_TIMING.Table 123: OS_Timing_GetCycles() parameter listReturn valueThe execution time in cycles as a 32-bit integer.Additional InformationCycle length depends on the timer clock frequency.ExampleThe following sample demonstrates the use of low-resolution and high-resolution measurement to return the executiontime of a section of code:#include "RTOS.H"#include OS_STACKPTR int Stack[1000]; /* Task stacks */OS_TASK TCB; /* Task-control-blocks */volatile int Dummy;void UserCode(void) {for (Dummy=0; Dummy < 11000; Dummy++); /* Burn some time */}/** Measure the execution time with low resolution and return it in ms (ticks)*/int BenchmarkLoRes(void) {int t;t = OS_GetTime();UserCode(); /* Execute the user code to be benchmarked */t = OS_GetTime() - t;return t;}/** Measure the execution time with hi resolution and return it in us*/OS_U32 BenchmarkHiRes(void) {OS_U32 t;OS_Timing_Start(&t);UserCode(); /* Execute the user code to be benchmarked */OS_Timing_End(&t);return OS_Timing_Getus(&t);}void Task(void) {int tLo;OS_U32 tHi;char ac[80];while (1) {tLo = BenchmarkLoRes();tHi = BenchmarkHiRes();PPRTOS-2117

Time measurementPrototypeOS_U32 OS_Timing_GetCycles (OS_TIMING* pCycle);ParameterDescriptionpCyclePointer to a data structure of type OS_TIMING.Table 123: OS_Timing_GetCycles() parameter listReturn valueThe execution time in cycles as a 32-bit integer.Additional InformationCycle length depends on the timer clock frequency.ExampleThe following sample demonstrates the use of low-resolution and high-resolution measurement to return the executiontime of a section of code:#include "<strong>RTOS</strong>.H"#include OS_STACKPTR int Stack[1000]; /* Task stacks */OS_TASK TCB; /* Task-control-blocks */volatile int Dummy;void <strong>User</strong>Code(void) {for (Dummy=0; Dummy < 11000; Dummy++); /* Burn some time */}/** Measure the execution time with low resolution and return it in ms (ticks)*/int BenchmarkLoRes(void) {int t;t = OS_GetTime();<strong>User</strong>Code(); /* Execute the user code to be benchmarked */t = OS_GetTime() - t;return t;}/** Measure the execution time with hi resolution and return it in us*/OS_U32 BenchmarkHiRes(void) {OS_U32 t;OS_Timing_Start(&t);<strong>User</strong>Code(); /* Execute the user code to be benchmarked */OS_Timing_End(&t);return OS_Timing_Getus(&t);}void Task(void) {int tLo;OS_U32 tHi;char ac[80];while (1) {tLo = BenchmarkLoRes();tHi = BenchmarkHiRes();PP<strong>RTOS</strong>-2117

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

Saved successfully!

Ooh no, something went wrong!