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

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

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

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

Saved successfully!

Ooh no, something went wrong!