IAR PowerPac RTOS User Guide
IAR PowerPac RTOS User Guide IAR PowerPac RTOS User Guide
System informationA running IAR PowerPac RTOS contains a number of system variables that are available for inspection. This windowlists the most important ones.SettingsTo be safe, the IAR PowerPac RTOS C-SPY plug-in imposes certain limits on the amount of information retrievedfrom the target, to avoid endless requests in case of false values in the target memory. This dialog box allows you totweak these limits in a certain range, for example if your task names are no longer than 32 characters you may set theMaximum string length to 32, or if they are longer than the default you may increase that value.After changing settings and clicking the OK button, your changes are applied immediately and should becomenoticeable after the next window update, for example when hitting the next breakpoint. However, the settings arerestored to their default values on plug-in reload.122IAR PowerPac RTOSfor ARM CoresPPRTOS-2
DebuggingRuntime errorsSome error conditions can be detected during runtime. These are:● Usage of uninitialized data structures● Invalid pointers● Unused resource that has not been used by this task before● OS_LeaveRegion() called more often than OS_EnterRegion()● Stack overflow (this feature is not available for some processors)Which runtime errors that can be detected depend on how much checking is performed. Unfortunately, additionalchecking costs memory and speed (it is not that significant, but there is a difference). If IAR PowerPac RTOS detectsa runtime error, it calls the following routine:void OS_Error(int ErrCode);This routine is shipped as source code as part of the module OS_Error.c. It simply disables further task switches andthen, after re-enabling interrupts, loops forever as follows:Example/*Run time error reaction*/void OS_Error(int ErrCode) {OS_EnterRegion(); /* Avoid further task switches */OS_DICnt =0; /* Allow interrupts so we can communicate */OS_EI();OS_Status = ErrCode;while (OS_Status);}When using an emulator, you should set a breakpoint at the beginning of this routine or simply stop the program aftera failure. The error code is passed to the function as parameter.You can modify the routine to accommodate your own hardware; this could mean that your target hardware sets anerror-indicating LED or shows a little message on the display.Note:When modifying the OS_Error() routine, the first statement needs to be the disabling of scheduler viaOS_EnterRegion(); the last statement needs to be the infinite loop.If you look at the OS_Error() routine, you will see that it is more complicated than necessary. The actual error codeis assigned to the global variable OS_Status. The program then waits for this variable to be reset. Simply reset thisvariable to 0 using your in circuit-emulator, and you can easily step back to the program sequence causing the problem.Most of the time, looking at this part of the program will make the problem clear.PPRTOS-2 123
- 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 and 116: Time measurementPrototypeU32 OS_Get
- Page 117 and 118: Time measurementPrototypeOS_U32 OS_
- Page 119 and 120: RTOS-aware debuggingThis chapter de
- Page 121: RTOS-aware debuggingTimersA softwar
- 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(). . .
DebuggingRuntime errorsSome error conditions can be detected during runtime. These are:● Usage of uninitialized data structures● Invalid pointers● Unused resource that has not been used by this task before● OS_LeaveRegion() called more often than OS_EnterRegion()● Stack overflow (this feature is not available for some processors)Which runtime errors that can be detected depend on how much checking is performed. Unfortunately, additionalchecking costs memory and speed (it is not that significant, but there is a difference). If <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> detectsa runtime error, it calls the following routine:void OS_Error(int ErrCode);This routine is shipped as source code as part of the module OS_Error.c. It simply disables further task switches andthen, after re-enabling interrupts, loops forever as follows:Example/*Run time error reaction*/void OS_Error(int ErrCode) {OS_EnterRegion(); /* Avoid further task switches */OS_DICnt =0; /* Allow interrupts so we can communicate */OS_EI();OS_Status = ErrCode;while (OS_Status);}When using an emulator, you should set a breakpoint at the beginning of this routine or simply stop the program aftera failure. The error code is passed to the function as parameter.You can modify the routine to accommodate your own hardware; this could mean that your target hardware sets anerror-indicating LED or shows a little message on the display.Note:When modifying the OS_Error() routine, the first statement needs to be the disabling of scheduler viaOS_EnterRegion(); the last statement needs to be the infinite loop.If you look at the OS_Error() routine, you will see that it is more complicated than necessary. The actual error codeis assigned to the global variable OS_Status. The program then waits for this variable to be reset. Simply reset thisvariable to 0 using your in circuit-emulator, and you can easily step back to the program sequence causing the problem.Most of the time, looking at this part of the program will make the problem clear.PP<strong>RTOS</strong>-2 123