IAR PowerPac RTOS User Guide
IAR PowerPac RTOS User Guide IAR PowerPac RTOS User Guide
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
- Page 65 and 66: MailboxesExampleSingle-byte mailbox
- Page 67 and 68: MailboxesPrototypevoid OS_GetMail (
- Page 69 and 70: MailboxesOS_WaitMail()DescriptionWa
- Page 71 and 72: QueuesWhy queues?In the preceding c
- Page 73 and 74: QueuesReturn valueThe size of the r
- Page 75 and 76: QueuesExamplestatic void MemoryTask
- Page 77 and 78: Task eventsIntroductionTask events
- Page 79 and 80: Task eventsExampleOS_WaitEventTimed
- Page 81 and 82: Task eventsPrototypechar OS_ClearEv
- Page 83 and 84: Event objectsIntroductionEvent obje
- Page 85 and 86: Event objectsExampleif (OS_EVENT_Wa
- Page 87 and 88: Event objectsExampleOS_EVENT_Reset(
- Page 89 and 90: Heap type memory managementANSI C o
- Page 91 and 92: Fixed block size memory poolsIntrod
- Page 93 and 94: Fixed block size memory poolsProtot
- Page 95 and 96: Fixed block size memory poolsProtot
- Page 97 and 98: StacksIntroductionThe stack is the
- Page 99 and 100: InterruptsIntroductionIn this chapt
- Page 101 and 102: InterruptsRules for interrupt handl
- Page 103 and 104: InterruptsOS_LeaveInterruptNoSwitch
- Page 105 and 106: InterruptsNesting interrupt routine
- Page 107 and 108: Critical RegionsIntroductionCritica
- Page 109 and 110: System variablesIntroductionThe sys
- Page 111 and 112: Configuration for your targetsystem
- Page 113 and 114: Time measurementIntroductionIAR Pow
- Page 115: Time measurementPrototypeU32 OS_Get
- Page 119 and 120: RTOS-aware debuggingThis chapter de
- Page 121 and 122: RTOS-aware debuggingTimersA softwar
- Page 123 and 124: DebuggingRuntime errorsSome error c
- Page 125 and 126: DebuggingValue Define Description17
- Page 127 and 128: Performance and resource usageThis
- Page 129 and 130: Performance and resource usageThe c
- Page 131 and 132: Performance and resource usage*/sta
- Page 133 and 134: ReentranceAll routines that can be
- Page 135 and 136: LimitationsThe following limitation
- Page 137 and 138: Source code of kernel and libraryIn
- Page 139 and 140: Additional modulesKeyboard manager:
- Page 141 and 142: FAQ (frequently asked questions)Q:
- Page 143 and 144: GlossaryActive TaskCooperativemulti
- Page 145 and 146: IndexIndexAAdditional modules . . .
- Page 147: IndexOS_WaitSingleEventTimed(). . .
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