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

The following table gives an overview about the variations of the context switch time depending on the memory typeand the CPU mode:Target OS version Memory CPU mode TimeATMEL AT91SAM7S256 3.32p Flash Thumb 8.92 usATMEL AT91SAM7S256 3.32p Flash ARM 9.32 usATMEL AT91SAM7S256 3.32p RAM ARM 6.28 usATMEL AT91SAM7S256 3.32p RAM Thumb 7.12 usTable 130: embOS context switch timesAll example performance values in the following section are determined with the following system configuration:ATMEL AT91SAM7S256 running with 48 MHz clock speed. All sources are compiled with IAR EmbeddedWorkbench version 4.41A using Thumb mode with high optimization level. The example program executes in of flashmemory.MEASUREMENT WITH PORT PINS AND OSCILLOSCOPEThe example file MeasureCST_Scope.c uses the LED.c module to set and clear a port pin. This allows measuringthe context switch time with an oscilloscope.The following source code is excerpt from MeasureContextSwitchingTime_Scope.c:#include "RTOS.h"#include "LED.h"static OS_STACKPTR int StackHP[128], StackLP[128]; // Task stacksstatic OS_TASK TCBHP, TCBLP;// Task-control-blocks/*********************************************************************** HPTask*/static void HPTask(void) {while (1) {OS_Suspend(NULL); // Suspend high priority taskLED_ClrLED0(); // Stop measurement}}/*********************************************************************** LPTask*/static void LPTask(void) {while (1) {OS_Delay(100); // Syncronize to tick to avoid jitter//// Display measurement overhead//LED_SetLED0();LED_ClrLED0();//// Perform measurement//LED_SetLED0(); // Start measurementOS_Resume(&TCBHP); // Resume high priority task to force task switch}}/*********************************************************************** main*/int main(void) {OS_IncDI();// Initially disable interruptsOS_InitKern();// Initialize OSOS_InitHW();// Initialize Hardware for OSLED_Init();// Initialize LED portsOS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP);OS_CREATETASK(&TCBLP, "LP Task", LPTask, 99, StackLP);OS_Start();// Start multitaskingreturn 0;}128IAR PowerPac RTOSfor ARM CoresPPRTOS-2

Performance and resource usageThe context switch time is the time between switching the LED on and off. If the LED is switched on with an activehigh signal, the context switch time is the time between rising and falling edge of the signal. If the LED is switched onwith an active low signal, the signal polarity is reversed.The real context switch time is shorter, because the signal also contains the overhead of switching the LED on and off.The time of this overhead is also displayed on the oscilloscope as a small peak right before the task switch time displayand has to be subtracted from the displayed context switch time.The following oscilloscope screenshots show the output of the MeasureContextSwitchingTime_Scope.cexample running on an AT91SAM7S256 processor with 48MHz clock speed.The small peak in the screenshot below shows the overhead which has to be subtracted from the context switch time.The time between the first falling edge and the first rising edge is the measurement overhead, in the example screenshotT1 = 320 ns.PPRTOS-2129

Performance and resource usageThe context switch time is the time between switching the LED on and off. If the LED is switched on with an activehigh signal, the context switch time is the time between rising and falling edge of the signal. If the LED is switched onwith an active low signal, the signal polarity is reversed.The real context switch time is shorter, because the signal also contains the overhead of switching the LED on and off.The time of this overhead is also displayed on the oscilloscope as a small peak right before the task switch time displayand has to be subtracted from the displayed context switch time.The following oscilloscope screenshots show the output of the MeasureContextSwitchingTime_Scope.cexample running on an AT91SAM7S256 processor with 48MHz clock speed.The small peak in the screenshot below shows the overhead which has to be subtracted from the context switch time.The time between the first falling edge and the first rising edge is the measurement overhead, in the example screenshotT1 = 320 ns.PP<strong>RTOS</strong>-2129

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

Saved successfully!

Ooh no, something went wrong!