Home

OSEKturbo OS Installation

image

Contents

1. Vee ReleaseMessageResource SymbolicName GetMessageStatus Message name Task all types syntax StatusType GetMessageStatus SymbolicName lt Message gt InitCOM syntax StatusType InitCOM void CloseCOM syntax StatusType CloseCOM void StartCOM Task all types syntax StatusType StartCOM void StopCOM syntax StatusType StopCOM Scalar lt ShutdownModes Messagelnit syntax StatusType Messagelnit void ReadFlag Flag name syntax FlagValue ReadFlag FlagType lt FlagName gt ResetFlag Flag name syntax StatusType Res etFlag FlagType lt FlagN ame gt lt MessageCallBack gt syntax void lt CallbackName gt void OSEKturbo OS MPC5xx For More Information www freescale com UM 55 Quick Reference Freescale Semiconductor Inc System Services Quick Reference Table A 1 OSEK OS Services Service Input Output Allowed In Debugging services GetRunningStackUsage Task ISR ErrorHook PreTaskHook PostTaskHook syntax unsigned short GetRunningStackUsage void GetStackUsage Task ISR ErrorHook PreTaskHook PostTaskHook Task name syntax unsigned short GetStackUsage TaskType lt TaskID gt GetTimeStamp Task ISR ErrorHook PreTaskHook PostTaskHook syntax unsigned short GetTimeStamp void Execution control servic
2. TerminateTask 4 Add the function CycleFunc before the task TASKC definition void CycleFunc void Countertt OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Tutorial Using Event and Extended Task The task TASKC performs the following actions in the application 1 The task TASKC is autostarted by the OS 2 The task clears Counter 3 4 The first step of the loop is setting a relative alarm AL1 which The task runs an infinite loop expires after 250 ticks of the counter TaskCounter after 1 ms Then WaitEvent service is called The task is transferred by this service to waiting state and keeps in this state until the alarm expires Another task can be running while TASKC waits for the next alarm AL1 expiration The function CycleFunc is called at the next step of the loop Therefore the function is called after each alarm AL1 has expired The last step of the loop is clearing the event in order to allow the waiting state at the next loop Then the task jumps to step 4 and repeats steps 4 7 This algorithm causes periodical calling of the function CycleFunc every 250 ticks of the counter TaskCounter every 1 ms The task TASKC shares CPU time with the TASKA and TASKB tasks which call each other The TASKC task s priority is higher than the TASKA and TASKB tasks ones Therefore TASKC interrupts TASKA or TASKB execution
3. The following standard parameters can be defined for the COUNTER object Table A 12 COUNTER Parameters Object Parameters Possible Values Description Standard Attributes MINCYCLE integer Specifies the minimum allowed number of counter ticks for a cyclic alarm linked to the counter MAXALLOWEDVALUE integer Defines the maximum allowed counter value TICKSPERBASE integer Specifies the number of ticks required to reach a counter specific value ALARM Object This object presents OS alarms The syntax of an alarm object is as follows ALARM lt name of ALARM gt COUNTER lt name of COUNTER gt ACTION lt SETEVENT ACTIVATETASK ALARMCALLBACK gt TASK lt name of TASK gt EVENT lt name of EVENT gt ALARMCALLBACKNAME lt string gt hi AUTOSTART lt TRUE FALSE gt ALARMTIME lt integer gt CYCLETIME lt integer gt APPMODE lt name of APPMODE gt OSEKturbo OS MPC5xx UM 73 For More Information www freescale com Quick Reference Freescale Semiconductor Inc OIL Language Quick Reference The following standard parameters can be defined for the ALARM object Table A 13 ALARM Parameters Object Parameters Possible Values Description Standard Attributes COUNTER name of COUNTER Specifies the assigned counter ACTION ACTIVATETASK Defines the method of notificati
4. Running Application To execute the application take the following steps 1 na A WwW N Open the command prompt window change the current directory to c userapp and execute the command mk Start the debugger Load file c userapp bin app el1f into the debugger Set a breakpoint to the found address of the CycleFunc function Reset and run the application The application will break on the function CycleFunc periodically The value Counter is increased on every break Add breakpoints at TASKA and TASKB functions You can see now that the CycleFunc function periodically interrupts the TASKA and TASKB tasks which call each other by rotation The OSEKturbo OS MPC5xx UM 33 For More Information www freescale com Tutorial Cyclic Alarm Freescale Semiconductor Inc TASKC task is preempted while waiting for the alarm AL1 expiration The TASKC task s priority is highest therefore the OS returns operation to the TASKC task straight after the alarm has expired and sets the event Cycle The diagram of task switching sequence is shown below TASKA TASKB TASKC CycleFunc alarm AL1 period A number of TASKA TASKB activations between adjacent CycleFunc calls depends on CPU clock frequency and can differ compared to the number shown at the diagram It can happen that the TASKA TAS
5. application header include lt appcfg h gt definitions for system objects int Counter CycleFunc entry counter TASK TASKB task B ChainTask TASKA Chain to TASKA TASKB is terminated by this service call TASKA is activated as a chain task TASKA will be transferred to the running state after TASKB termination void CycleFunc void This function is called periodically Counter Increment entry counter TASK TASKC Counter 0 initialize counter SetRelAlarm AL1 10 10 Set cyclic alarm WaitEvent Cycle Wait alarm AL1 expiration StartTimeScale Start Time Scale while 1 infinite loop ClearEvent Cycle Clear event WaitEvent Cycle Wait alarm AL1 expiration Call CycleFunc when alarm set event CycleFunc This line is never reached TASK TASK1 TerminateTask TASK TASK2 OSEKturbo OS MPC5xx UM 45 For More Information www freescale com Freescale Semiconductor Inc Tutorial Listing TerminatetTask TASK TASK3 TerminatetTask File app h ifndef APP _H define APP_H endif APP_H UM 46 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Using an Unsupported Target Derivatives The chapter contains recommendations for the OSEK OS adaptation to other
6. Object Parameters Possible Values Description Global System Attributes This group of OS attributes represents system features which are common for the whole system syntax The attributes should be defined inside the scope of t STATUS lt STANDARD EXTENDE DEBUG_LEVEL BuildNumber FastTerminate FastScheduler CC lt BCCl ECC1 AUTO gt lt 0 1 2 4 lt TRUE FALSE gt he OS object in accordance with the following D gt gt A lt TRUE FALSE gt lt TRUE FALSE gt MessageCopyAllocation lt USER OS gt ResourceScheduler lt TRUE FALSE gt STATUS STANDARD This standard attribute specifies OS debug status EXTENDED standard CC BCC1 ECC1 AUTO Specifies OSEK Conformance Class specific DEBUG_LEVEL p Specifies the ORTI support in OS 2 Era specific 4 BuildNumber TRUE Specifies whether build number in ASCII form iti FALSE should be incorporated into OS binary image eee ROM code or not FastTerminate TRUE Specifies whether the fast version of Terminate FALS ChainTask is used in BCC1 class specific FastScheduler TRUE Specifies whether the OS places global variables FALS into CPU general purpose registers specific MessageCopyAllocation USER 4 Specifies whether the System Generator i os generates copies of messages in global memory acra
7. PRIORITY 2 SCHEDULE FULL AUTOSTART TRUE ACTIVATION 1 hy TASK TASKB PRIORITY 1 SCHEDULE FULL AUTOSTART FALSE ACTIVATION 1 hy The APPMODE object does not require any attributes There are no any resources ISRs events and timers in this small application BCC class is selected automatically by SysGen You can find below complete listing of the appcfg oil file OIL VERSION 2 3 include ost22mpc oil CPU cpudl APPMODE Mode OS osl STATUS EXTENDED TargetMCU MPC555 j STARTUPHOOK FALSE SHUTDOWNHOOK FALSE PRETASKHOOK FALSE POSTTASKHOOK FALSE ERRORHOOK FALSE USEGETSERVICEID FALSE USEPARAMETERACCESS FALSE j TASK TASKA PRIORITY 2 SCHEDULE FULL AUTOSTART TRUE ACTIVATION 1 OSEKturbo OS MPC5xx UM 19 For More Information www freescale com Freescale Semiconductor Inc Tutorial Creating New Application ie TASK TASKB PRIORITY 1 SCHEDULE FULL AUTOSTART FALSE ACTIVATION 1 hy hy Source Code Two source files will be used in the application Each of them contains one task Take the following steps to create a source code 1 Create a file app1 c in the directory and add the following code to the file include osprop h OS Properties file include lt osapi h gt OSEK API declarations finclude app h application header include lt appcfg h gt defi
8. Task value Ty InitCounter CtrRefType lt CounterlD gt TickType CounterTrigger Counter name Task ISR syntax StatusType CounterTrigger CtrRefT ype lt CounterlD gt GetCounterValue Counter name Counter value Task ISR ErrorHook PreTaskHook PostTaskHook ay StatusType GetCounterValue CtrRefType lt CounterlD gt ickRefType lt TicksRef gt GetCounterlnfo Counter name Counter constants Task ISR ErrorHook PreTaskHook PostTaskHook syntax StatusType GetCounterlnfo CtrRefType lt CounterlD gt trinfoRefType lt InfoRef gt OSEKturbo OS MPC5xx UM 53 For More Information www freescale com Freescale Semiconductor Inc Quick Reference System Services Quick Reference Table A 1 OSEK OS Services Service Input Output Allowed In Alarm management services GetAlarmBase Alarm name Alarm constants Task ISR ErrorHook PreTaskHoo Post laskHook AlarmBaseRefType lt InfoRef gt syntax Status Spe GetAlarmBase AlarmType lt AlarmID gt GetAlarm Alarm name Relative value in ticks Task ISR ErrorHook before the alarm PreTaskHook expires PostTaskHook ene StatusType GetAlarm AlarmType lt AlarmID gt TickRefType icksRef gt SetRelAlarm Alarm name Counter Task ISR relative value Cycle value syntax StatusType SetRelAlarm AlarmType lt AlarmID gt TickType lt Increment gt TickType lt Cycle gt
9. lt integer AUTO gt Freeze lt TRUE FALSE gt RTSEL lt EXTCLK OSCM gt hi hi HCLowPower lt TRUE FALSE gt TargetMCU MPC555 MPC561 Specifies target MCU type specific MBS563 MPC56S OSEKturbo OS MPC5xx UM 65 For More Information www freescale com Quick Reference Freescale Semiconductor Inc OIL Language Quick Reference Table A 7 OS Parameters Object Parameters Possible Values Description ClockDivider integer Specifies PLL divider ae for calculating ifi input timer frequency The attribute is applicable if specie the TimerHardware attribute has DEC TBO or TB1 value ClockMultiplier integer Specifies PLL multiplier MF 1 for calculating ifi input timer frequency The attribute is applicable if specrie the TimerHardware attribute has DEC TBO or TB1 value SysTimer HWCOUNTER Defines whether the internal OS system timer is fic SWCOUNTER used or not The attribute can not be defined if speciiic NONE TargetMCU is set to MPC SecondTimer HWCOUNTER Defines whether the internal OS second timer is fic SW COUNTER used or not The attribute can not be defined if speciiic NONE TargetMCU is set to MPC COUNTER name of COUNTER Specifies the COUNTER which shall be attached i to the system or second timer The same counter vent can not be attached to the System and Second timers
10. SetAbsAlarm Alarm name Counter Task ISR absolute value Cycle value sex StatusType SetAbsAlarm AlarmType lt AlarmID gt TickType lt Start gt ickType lt Cycle gt CancelAlarm Alarm name Task ISR syntax StatusType CancelAlarm AlarmType lt AlarmID gt lt AlarmCallBack gt an syntax ALARMCALLBACK lt CallbackName gt StartTimeScale Task syntax void StartTimeScale void StopTimeScale Task ISR all hook routines syntax void StopTimeScale void Message management services SendMessage Message name Task all messages ISR message data unqueued WithCopy syntax Teus Type SendMessage SymbolicName lt Message gt AccessNameRef lt Data gt UM 54 OSEKturbo OS MPC5xx For More Information www freescale com Table A 1 Freescale Semiconductor Inc OSEK OS Services Quick Reference System Services Quick Reference Service Input Output Allowed In ReceiveMessage Message name Message data Task all types ErrorHook un ueued WithCopy fanqueued WihCopy syntax StatusType Rec eiveMessage SymbolicName lt Message gt AccessNameRef lt Data gt GetMessageResource Message name Task WithoutCopy syntax StatusType GetMessageResource Sym bolicName lt Message gt ReleaseMessageResource Message name Task WithoutCopy
11. TRUE ACTIVATION 1 The task TASKC is autostarted It has the highest priority Therefore TASKC is the first started task and any other task can not interrupt the task TASKC 3 Save appcfg oili file UM 26 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Tutorial Additional Task Source Code The next step is creation of the task TASKC source code The only action of this function is terminating itself Take the following steps to modify the application code 1 Open file c userapp app2 c ina text editor 2 To define the task TASKC add the following code to the end of file app2 c TASK TASKC TerminateTask 3 Save file c userapp app2 c Running Application To execute the application take the following steps 1 Open the command prompt window 2 Change the current directory to c userapp 3 Execute the command mk Files mk bat and makefile have been created in MakeFile They have not been modified Start the debugger Load file c userapp bin app elf into the debugger Set breakpoints at TASKA TASKB and TASKC functions Reset and run the application The application will break on the task TASKC Then the application will break on the task TASKA and TASKB by rotation YA wns The diagram of task switching sequence is shown below TASKA TASKB TASKC
12. Inc Quick Reference OIL Language Quick Reference ISR lt name of ISR gt CATEGORY lt 1 2 gt PRIORITY lt integer gt RESOURCE lt name of RESOURCE gt ACCESSOR lt SENT RECEIVED gt MESSAGE lt name of MESSAGE gt ACCESSNAME lt string gt hy The following parameters can be defined for the ISR object Table A 9 ISR Parameters Object Parameters Possible Values Description Standard Attributes CATEGORY 1 2 Specifies the category of interrupt service routine RESOURCE name of RESOURCE Specifies the list of resources accessed by the task The reference can not be defined if CATEGORY is 1 There can be several resource references ACCESSOR SENT RECEIVED Defines the type of usage for the message MESSAGE name of MESSAGE epee the message to be sent or received by the ACCESSNAME string Defines the reference which can be used by the application to access the message data OSEKturbo Specific Attributes PRIORITY ae 16 or 0 48 for Specifies the priority of the interrupt service routine nhanced InterruptDispatcher RESOURCE Object The RESOURCE object is intended for the resource management The syntax of the resource object is as follows RESOURCE lt name of resource gt RESOURCEPROPERTY lt STANDARD LINKED INTERNAL gt LINKEDRESOURCE lt name of RESOURCE gt OSEKturbo OS
13. Inc Quick Reference OIL Language Quick Reference The following standard parameters can be defined for the MESSAGE object Table A 14 MESSAGE Parameters Object Parameters Possible Values Description Standard Attributes TYPE QUEUED UNQUEUED Specifies the message type QUEUEDEPTH integer Specified if the message has a queue CDATATYPE string Defines the data type of a message item ACTION ACTIVATETASK Defines the type of task notification used when the SETEVENT message has arrived CALLBACK FLAG NONE TASK name of TASK Specifies the task which shall be notified when the message has arrived It shall be defined if ACTION is ACTIVATETASK or SETEVENT only EVENT name of EVENT Specifies the event to be set when the message has arved It shall be defined if ACTION is SETEVENT only CALLBACKNAME string Defines the name of a function to call as an action when the mensage has been sent It shall be defined if ACTION is CALLBACK only FLAGNAME string Defines the name of the flag that is set when the message is sent It shall be defined if ACTION is FLAG only APPMODE Object The APPMODE object is intended for the application mode management This object has no standard parameters COM Object The COM object represents the OSEK communication subsystem properties on CPU Only one COM object must be defined on the local CPU The syntax scheme of a COM object is as follows OSEKturbo OS MPC5xx
14. OSEK Implementation Language file for MPCS555 platform and Diab Data compiler cfg563cw oil OSEK Implementation Language file for MPC563 platform and CodeWarrior compiler cfg563db 0i1 OSEK Implementation Language file for MPC563 platform and Diab Data compiler OSEKturbo OS MPC5xx UM 13 For More Information www freescale com Freescale Semiconductor Inc Sample Application Building Sample cfg565cw oil OSEK Implementation Language file for MPC565 platform and CodeWarrior compiler cfg565db 0i1 OSEK Implementation Language file for MPC565 platform and Diab Data compiler Each OIL file accompanied by the couple of the OSEK Builder configuration files which have the same name and app and pws extensions These files provide the user with possibility to configure and build the OS with OSEK Builder msmake bat command file for compiling sample using Microsoft nmake utility gnumake bat command file for compiling sample using GNU make utility The directory structure of the Sample application is described in the readme txt file located in the sample standard directory Building Sample Take the following steps to build the sample application 1 Open the Windows command prompt window 2 Change the current directory to sample standard lt derivative gt directory which contains sample source files Hereafter the lt derivative gt term shall be used for meaning the
15. OSEKturbo OS MPC5xx UM 27 For More Information www freescale com Freescale Semiconductor Inc Tutorial Adding Single Alarm Adding Single Alarm This section contains a description how to add an alarm to the application The system timer will be used to increment the counter attached to the alarm The alarm will be set to a relative value by the task TASKC Then TASKC terminates itself and TASKA is transferred to running state When the alarm expires it activates the task TASKC TASKC has the highest priority therefore it interrupts TASKA or TASKB The task TASKC sets the alarm again and terminates itself This process will repeat periodically TASKA and TASKB are working in background Configuration File To use a system timer counter and alarm in the application corresponding objects shall be added to the OIL file Take the following steps 1 To define the System Timer we have to choose the hardware source of the timer interrupts which are handled by the OS and to define parameters to configure the period for the system timer There are two types of the system timer supported by the OS HWCOUNTER and SWCOUNTER The HWCOUNTER has a less system overhead because the interrupts occur only if an alarm attached to the counter expires But the HWCOUNTER does not use the whole set of the timer hardware sources So the decision which type of the system timer to choose shall be based on the available hardware and application requirement
16. Similar results can be achieved using an extended task and an event It allows the application to avoid task restarting The extended task will be autostarted and never terminated The task will periodically activate a function with a period of alarm AL1 Between adjacent function calls the extended task will be transferred into waiting state UM 30 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Tutorial Using Event and Extended Task Configuration File The task TASKC will be used as extended task To adjust the task and to add an event corresponding objects shall be prepared in the OIL file Take the following steps 1 Open c userapp appcfg oil file in a text editor 2 Add a reference to the event to a TASKC object Here is the corrected code of this object TASK TASKC PRIORITY 3 SCHEDULE FULL AUTOSTART TRUE ACTIVATION 1 EVENT Cycle STACKSIZE 256 The task TASKC is autostarted It has a reference to the event Cycle Therefore it is an extended task Existence of the extended task leads to ECC 1 Conformance Class which is selected automatically by the System Generator The task TASKC has the highest priority Therefore any other task can only preempt TASKC if the task TASKC is terminated or transferred to waiting state 3 Since the TASKC is an extended task which has a separate stack and there is a System Timer ISR c
17. A 8 TASK Parameters Object Parameters Possible Values Description Standard Attributes PRIORITY meger Defines the priority of the task The lowest priority 0 0x7FFFFFFF has value 0 SCHEDULE FULL NON Defines the run time behavior of the task AUTOSTART TRUE FALSE Defines whether the task is activated during the system start up procedure or not APPMODE name of APPMODE Defines an application mode in which the task is auto started ACTIVATION 1 Specifies the maximum number of queued activation requests for the task The OSEKturbo OS does not URPON multiple activation so this value is restricted O RESOURCE name of RESOURCE Resources accessed by the task There can be several resource references EVENT name of EVENT Events owned by the task There can be several event references ACCESSOR SENT RECEIVED Defines the type of usage for the message MESSAGE name of MESSAGE A the message to be sent or received by the as WITHOUTCOPY TRUE FALSE S whether a local copy of the message is used or no ACCESSNAME string Defines the reference which can be used by the application to access the message data OSEKturbo Specific Attribute STACKSIZE integer Defines the size of the extended task s stack in bytes ISR Object This object represents an Interrupt Service Routine Parameters of this object type define ISR properties The syntax of the ISR object is as follows UM 70 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor
18. Period tee Specifies period of a tick of the system second AUTO counter in nanoseconds specific TimerHardware PIT DEC RTC TBO The attribute is intended to select the hardware fic 181 interrupt source for the system and second eae counters The TimerHardware attributes in SysTimer and SecondTimer blocks can not have the same value Prescaler USER Specifies whether prescaler value shall be fic OS initialized during OS startup or it is set by the SREE user s code Value in Prescaler integer AUTO Defines initial prescaler value Note that this i attribute value is not equal to divide factor of timer Pere hardware TimerModuloValue integer AUTO Specifies timer hardware register value specific Freeze TRUE Defines whether timer stops or not if breakpoint is FALSE achieved in the debugger specific RTSEL EXTCLK Specifies clock source for RTC and PIT timers OSCM specific HCLowPower TRUE Defines that low power mode shall be used when FALS there are no ready or running tasks specific ISRSourceControl TRUE Defines that OS uses IMR registers in Suspend FALS ResumeOSinterrupts functions specific UM 66 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Quick Reference OIL Language Quick Reference Table A 7 OS Parameters Object Parameters Possible Values Description Stack Related Attrib
19. ResumeAlllnterrupts Task ISR category 1 and 2 alarm callbacks syntax void ResumeAlllnterrupts void SuspendAlllnterrupts Task ISR category 1 and 2 alarm callbacks syntax void SuspendAlllnterrupts void ResumeOSInterrupts task ISR category 1 and syntax void ResumeOSInterrupts void SuspendOS Interrupts ask ISR category 1 and syntax void SuspendOSInterrupts void Resource management services GetResource Resource name Task ISR syntax StatusType GetResource ResourceType lt ResID gt ReleaseResource Resource name Task ISR syntax StatusType ReleaseResource ResourceType lt ReslD gt UM 52 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Quick Reference System Services Quick Reference Table A 1 OSEK OS Services Service Input Output Allowed In Event control services SetEvent Jess vanes Event Task ISR Veo TYPS SetEvent TaskType lt TaskID gt EventMaskType ClearEvent Event mask Extended task syntax StatusType ClearEvent EventMaskType lt Mask gt GetEvent Task name Event mask Task ISR ErrorHook Poot fas aSk Ea ae GetEvent TaskType lt TaskID gt EventMaskRefType WaitEvent Event mask Extended task syntax StatusType WaitEvent EventMaskType lt Mask gt Counter management services InitCounter Counter name initial
20. UM 75 For More Information www freescale com Freescale Semiconductor Inc Quick Reference OIL Language Quick Reference COM lt name of COM gt USEMESSAGERESOURCE lt TRUE FALSE gt USEMESSAGESTATUS lt TRUE FALSE gt The object has the following standard attributes Table A 15 COM Parameters Object Parameters Possible Values Description Standard Attributes USEMESSAGERESOURCE_ TRUE FALSE Specifies if the message resource mechanism is use USEMESSAGESTATUS TRUE FALSE Specifies if the message status is available NM Object The NM object represents the local parameters of the network management subsystem on CPU This object has no standard parameters UM 76 OSEKturbo OS MPC5xx For More Information www freescale com
21. UserTimerHandler CATEGORY 2 PRIORITY 15 UM 48 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Using an Unsupported Target Derivatives System Timer 2 Add COUNTER object to the OIL file This counter will be increased by the SysHandler routine The value of the counter attributes should be set according to the application algorithm The values shown below are an example only COUNTER UserCounter MINCYCLE 3 MAXALLOWEDVALUE 255 TICKSPERBASE 10 3 Create a function InitializeTimer in the application source file This function should contain a code for hardware timer initialization and timer start up The function should be called in the StartupHook or from the autostarted task void InitializeTimer initialize timer hardware registers enable interrupts from the timer start the timer 4 If itis planned to use ShutdownOS service then create a function ShutdownTimer This function should contain a code for switching off the hardware timer and disabling timer interrupts The function should be called after ShutdownOS service calling or in the ShutdownHook void ShutdownTimer disable interrupts from the timer stop the timer reset timer hardware registers 5 Create ISR category 2 and add the following code to it This ISR will be used as a timer interrupt han
22. bin app into the debugger 4 Set breakpoints at TASK1 TASK2 TASK3 and CycleFunc functions 5 Reset and run the application After the first break on CycleFunc the TimeScale will be started and control will be passed to TASK For More Information www freescale com Freescale Semiconductor Inc Tutorial Listing the first task in TimeScale activated immediately Then the application will break on those functions periodically The diagram of task switching sequence is shown below Time scale period lt lt P TASK1 j TASK2 TASK3 TASKA TASKB TASKC CycleFunc alarm AL1 period A number of TASKA TASKB activations between adjacent CycleFunc calls depends on CPU clock frequency and can differ compared to the number shown at the diagram You can find below a complete listing of the updated source files This listing corresponds to the application described in TimeScale File appcfg oil OIL_VERSION 2 3 include ost22mpc oil CPU cpul APPMODE Mode OS osl STATUS EXTENDED TargetMCU MPC555 OSEKturbo OS MPC5xx UM 41 For More Information www freescale com Freescale Semiconductor Inc Tutorial Listing ClockFrequency 4000 SysTimer HWCOUNTER COUNTER TaskCounter SRPRIORITY 8 Period 4000 hi SecondTimer SWCOUNTER COUNTER TaskCounter SRPRIORITY 16 TimerHardware DEC Pre
23. derivatives The current version of the OSEK OS supports MPC555 MPCS561 MPCS563 and MPC565 MCUs directly The user can try to adapt the OSEK OS to other MPC derivatives The OSEK OS will work correctly in most cases This chapter consists of the following sections e Target MCU Type e Vector Table e System Timer e Make File Target MCU Type If you want to use the OSEK OS with other derivatives set TargetMCU option to MPC This value turns off derivative specific features which can cause some problems if the OSEK OS runs on an unsupported MCU The main restriction is impossibility of the system and the second timers definition SysTimer and SecondTimer blocks can not be defined in the OS section of the OIL file Therefore the user should define a timer in an application if the timer is needed The following restrictions are also applicable for TargetMCU equal to MPC e ClockFrequency ClockDivider and ClockMultiplier attributes are not applicable If it is planned to use an unsupported MCU which structure is close to one of the MCUs supported by the OSEK OS the TargetMCU attribute can be set to another value than MPC It allows configuring timers by the System OSEKturbo OS MPC5xx UM 47 For More Information www freescale com Freescale Semiconductor Inc Using an Unsupported Target Derivatives Vector Table Generator If you try to use the value MPC555 with another derivative please be very careful Different der
24. does not do anything else 3 Create a header file app h in the same directory This file is required for message types and user types declarations Add the following code to the file ifndef APP_H define APP_H endif APP_H NOTE 4 Copy the file vector c from SOSEKDIR hwspec directory to c userapp directory This source file contains the start up code and interrupt vector table definition You can modify the vector c file in the application directory or create your own application vector table to fit it to a specific application see Vector Table DO NOT change the vector c file in the SOSEKDIR hwspec directory This file is used as a template and for a sample application building OSEKturbo OS MPC5xx UM 21 For More Information www freescale com Tutorial Creating New Application UM 22 Freescale Semiconductor Inc MakeFile The Makefile from a sample application included in the OSEK OS package can be used for compiling the example The Makefile for the Microsoft NMAKE utility is used in this example If you want to use the makefile for the GNU MAKE utility follow the instructions but take files of the GNUMAK directory instead of files of the MSMAK one Before a makefile construction you have to select a compiler and a platform The choice defines the template for a new makefile You can use the following templates from SOSEKD R sample standard lt derivative g
25. freescale com Freescale Semiconductor Inc Tutorial Creating New Application OIL VERSION 2 3 include ost22mpc oil 4 Add a CPU section to the OIL file Fill the CPU section with two mandatory objects APPMODE and OS Add two TASK objects into the CPU section Give them names as follows CPU cpul APPMODE Mode OS os1 TASK TASKA TASK TASKB 5 Add eight mandatory attributes to the OS section They define that the application will work in EXTENDED status and no hooks are used OS osl STATUS EXTENDED STARTUPHOOK FALSE SHUTDOWNHOOK FALSE PRETASKHOOK FALSE POSTTASKHOOK FALSE ERRORHOOK FALSE USEGETSERVICEID FALSE USEPARAMETERACCESS FALSE be 6 To define the target derivative add the following attributes into the OS section TargetMCU MPC55500 hy TargetMCU attribute defines type of CPU Two tasks are to be defined in the O L file They are full preemptable Basic tasks TASKA priority is higher than TASKB priority TASKA is started automatically by OS 7 To configure tasks add the following attributes into the TASKA and TASKB objects UM 18 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Tutorial Creating New Application TASK TASKA
26. install OSEKturbo OS MPC5xx Sample Application chapter provides the user with definition of the sample application and instructions how to build the sample application Tutorial chapter contains description how to create a new simple application Using an Unsupported Target Derivatives chapter contains recommendations about OSEK OS adaptation to other derivatives Quick Reference appendix lists OSEK OS run time services with entry and exit conditions as well as OIL object parameters with their possible values and short descriptions This chapter consists of the following sections e OSEK OS Overview e Technical Support Information OSEK OS Overview OSEK Operating System is a real time operating system which conforms to the OSEK OS v 2 2 specification The OSEK OS meets the following requirements e OS is fully configured and statically scaled e OS performance parameters are well known The most part of the OS is written in strict correspondence with ANSI C standard the OS and the application on its basis can be easily ported from one platform to another OSEKturbo OS MPC5xx UM 5 For More Information www freescale com Freescale Semiconductor Inc Introduction Technical Support Information A wide range of scalability a set of system services various scheduling mechanisms and convenient configuration features make the OSEK Operating System feasible for a broad spectrum of app
27. name of the subdirectory which keeps the target specific files For example a mpc555 subdirectory 3 If you use the Microsoft nmake utility execute the following command msmake bat lt compiler gt where lt compiler gt is a specific compiler name and can be set to codewarrior for CodeWarrior compiler or diab for Diab Data compiler If you use GNU make utility execute the following command gnumake bat lt compiler gt NOTE If some of compiler OSEK OS or System Generator files are not found during building check accuracy of the paths defined in the sample standard common environment bat file UM 14 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Sample Application Building Sample 4 After completion of the building the following subdirectories and files are created in the sample directory e gen subdirectory contains cfg lt target gt c files cfg lt target gt h and osprop h files generated by SysGen where lt target gt is defined by the derivative and the used compiler like in name of the corresponding OIL file e obj subdirectory contains object files e bin subdirectory contains the executable file linker map and ORTI file e To execute the sample application load the executable file placed in the bin subdirectory to the evaluation board using the debugger e To clean all files generated during the sample building execute one of the following commands msm
28. the alarm expires Another task can be running while the TASKC is waiting for the next alarm AL1 expiration 6 The function CycleFunc is called at the next step of the loop Therefore the function is called after each time when the alarm AL1 has expired 7 The last step of the loop is clearing the event in order to allow transferring into waiting state at the next loop Then the task jumps to step 5 and repeats steps 5 7 This algorithm causes periodical calling of the function CycleFunc every ticks of the counter TaskCounter OSEKturbo OS MPC5xx UM 35 For More Information www freescale com Tutorial TimeScale TimeScale UM 36 Freescale Semiconductor Inc The task TASKC shares CPU time with the TASKA and TASKB tasks which call each other The task TASKC priority is higher than the TASKA and TASKB tasks ones Therefore TASKC interrupts TASKA or TASKB execution Running Application To execute the application take the same steps as described in Using Event and Extended Task The diagram of task switching sequence is shown below TASKA TASKB TASKC CycleFunc alarm AL1 period A number of TASKA TASKB activations between adjacent CycleFunc calls depends on CPU clock frequency and can differ compared to the number shown at the diagram It can happen that the TASKA TASKB execu
29. Freescale Semiconductor Inc OSEKturbo OS MPC5xx V 2 2 1 User s Manual Because of last minute software changes some information in this manual may be inaccurate Please read the readme txt file for the latest information Revised June 2003 For More Information www freescale com Freescale Semiconductor Inc 2003 MOTOROLA ALL RIGHTS RESERVED Motorola reserves the right to make changes without further notice to any products herein to improve reliability function or design Motorola does not assume any liability arising out of the application or use of any product or circuit described herein neither does it convey any license under its patent rights nor the rights of others Motorola products are not designed intended or authorized for use as components in systems intended for surgical implant into the body or other applications intended to support or sustain life or for any other application in which the failure of the Motorola product could create a situation where personal injury or death may occur Should Buyer purchase or use Motorola products for any such unintended or unauthorized application Buyer shall indemnify and hold Motorola and its officers employees subsidiaries affiliates and distributors harmless against all claims costs damages and expenses and reasonable attorney fees arising out of directly or indirectly any claim of personal injury or death associated with such unintended or unauthorized use eve
30. KB execution cycle and the alarm cycle do not have a common multiple Therefore the number of TASKA and TASKB activations can vary slightly in different CycleFunc executions Cyclic Alarm UM 34 The Cyclic alarm can be used instead of periodically setting of the single alarm It allows a more accurate controlling the period This section describes how to change a single alarm to a cycle one and to keep the previous functionality There is no need to modify OIL file Only the TASKC source code will be corrected OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Tutorial Cyclic Alarm Source Code To use the cyclic alarm instead of a single one take the following steps 1 Open c userapp app2 c file in a text editor 2 Correct the TASKC code according to the following template TASK TASKC Counter 0 SetRelAlarm AL1 250 250 while 1 WaitEvent Cycle CycleFunc ClearEvent Cycle TerminateTask Now the task TASKC performs the following actions in the application 1 The task TASKC is autostarted by the OS 2 The task clears Counter 3 It sets a relative alarm AL1 which expires periodically every 250 ticks of the counter TaskCounter every 1 ms 4 The task TASKC runs an infinite loop 5 The first step of the loop is waiting for an event which transfers the task to waiting state and the task keeps in this state until
31. MPC5xx UM 71 For More Information www freescale com Freescale Semiconductor Inc Quick Reference OIL Language Quick Reference The following standard parameters can be defined for the RESOURCE object Table A 10 RESOURCE Parameters Object Parameters Possible Values Description Standard Attributes RESOURCEPROPERTY STANDARD LINKED Specifies a property of the resource Performance decreases if RESOURCE with INTERNAL RESOURCEPROPERTY INTERNAL defined LINKEDRESOURCE name of RESOURCE Specifies the resource to which the linking shall be performed EVENT Object The EVENT object is intended for the event management The syntax of the event object is as follows EVENT lt name of EVENT gt MASK lt integer AUTO gt The following standard parameters can be defined for the EVENT object Table A 11 EVENT Parameters Object Parameters Possible Values Description Standard Attribute MASK integer AUTO Represents the event COUNTER Object Attributes of this object type define counter properties The syntax of the counter object is COUNTER lt name of COUNTER gt MINCYCLE lt integer gt UM 72 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Quick Reference OIL Language Quick Reference MAXALLOWEDVALUE lt integer gt TICKSPERBASE lt integer gt
32. Reference The list of all OSEK Operating System run time services is provided below Input and output parameters syntax and ability to use by OSEK entities are shown Note that ISR means ISR category 2 if not specified else Table A 1 OSEK OS Services Service Input Output Allowed In Task management services ActivateTask Task name Task ISR syntax StatusType ActivateTask TaskType lt TasklD gt TerminateTask Task syntax StatusType TerminateTask void ChainTask Task name Task syntax StatusType ChainTask TaskType lt TaskID gt Schedule Task syntax StatusType Schedule void GetTaskld Task name Task ISR ErrorHook PreTaskHook PostTaskHook syntax StatusType GetTaskld TaskRefType lt TaskIDRefs OSEKturbo OS MPC5xx UM 51 For More Information www freescale com Quick Reference Freescale Semiconductor Inc System Services Quick Reference Table A 1 OSEK OS Services Service Input Output Allowed In GetTaskState Task name Task state Task ISR ErrorHook PreTaskHook PostTaskHook lt StateRefs syntax StatusType GetTaskState TaskType lt TaskID gt TaskStateRefType Interrupt management services EnableAlllnterrupts oa ISR category 1 and syntax void EnableAlllnterrupts void DisableAlllnterrupts PaSk ISR category 1 and syntax void DisableAlllnterrupts void
33. SK1 PRIORITY 4 SCHEDULE FULL AUTOSTART FALSE ACTIVATION 1 TASK TASK2 PRIORITY 5 SCHEDULE FULL AUTOSTART FALSE ACTIVATION 1 TASK TASK3 PRIORITY 6 SCHEDULE FULL AUTOSTART FALSE ACTIVATION 1 be 3 To configure the TimeScale the following statements shall be added to the OS section TimeScale TRUE TimeUnit ms Step SET OSEKturbo OS MPC5xx UM 37 For More Information www freescale com Tutorial TimeScale UM 38 Freescale Semiconductor Inc StepNumber 1 StepTime 5 TASK TASK1 hi Step SET StepNumber 2 StepTime 2 TASK TASK2 Step SET StepNumber 3 StepTime 3 TASK TASK3 bi The configured TimeScale has three steps at the first step TASK1 starts the second step is 5 milliseconds after the first step and TASKk2 is activated the third step is 2 milliseconds after the second step and TASK3 is activated 3 milliseconds after the third step the TimeScale will execute the first step All the time intervals for the TimeScale are configured in milliseconds the TimeUnit ms statement allows the definition of time measurement units for the TimeScale ticks of the System Timer are used by default To keep the existing application part which serves periodic event setting for TASKC the TaskCounter with the atta
34. TACK 17 Task stack overflow E OS SYS ORDER 18 Incorrect order of function calling E OS SYS _MAINSTACK 19 Main stack overflow E OS _SYS_ISRSTACK 20 ISR stack overflow E COM_BUSY 33 Message in use by application task function E COM_ID 35 Invalid message name passed as parameter E COM_LIMIT 36 Overflow of FIFO associated with queued messages E COM_LOCKED 39 Rejected service call message object locked due to a pending operation E COM _NOMSG 41 No message available z e A is not defined in the OSEK OS v 2 2 specification This is OSEKturbo extension of the The list of service identifiers for ErrorHook is provided below e identifieirs for standard OSEK services OSServiceld_StartOS OSServiceId_ShutdownOS OSServiceld_GetActiveApplicationMode OSServiceld_ActivateTask UM 60 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Quick Reference System Services Quick Reference OSServiceIld_TerminateTask OSServiceId_ChainTask OSServiceld_Schedule OSServiceId_GetTaskID OSServiceId_GetTaskState OSServiceId_ResumeAllInterrupts OSServiceld_SuspendAllinterrupts OSServiceId_ResumeOSInterrupts OSServiceId_SuspendOSinterrupts OSServiceId_EnableAllInterrupts OSServiceld_DisableAllInterrupts OSServiceId_GetResource OSServiceId_ReleaseResource OSServiceId_SetEvent OSServiceId_ClearEvent OSServiceld_GetEvent OSServiceId_WaitEvent OSServiceId_SendMessage OSServiceId_Rec
35. ake clean gnumake clean OSEKturbo OS MPC5xx UM 15 For More Information www freescale com Freescale Semiconductor Inc Sample Application Building Sample UM 16 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Tutorial The chapter describes how to create a new simple application This chapter consists of the following sections Creating New Application Additional Task Adding Single Alarm Using Event and Extended Task Cyclic Alarm TimeScale Listing Creating New Application This example has two tasks which activate each other cyclically Each of the tasks is placed in a separate source file Configuration File A very simple OIL file will be used in an application However it performs configuring of a small application One application mode will be defined As much as possible attributes will be omitted default values will be used by the System Generator To create an application source code take the following steps 1 Create a new directory for example c userapp 2 Create an OSEK OS configuration file appcfg oil in the directory c userapp 3 Add OIL version and OIL implementation include file to the appcfg oil file The implementation supplied with the OSEK OS is used for this sample Please find the implementation file in OSEKturbo OS MPC5xx the SOSEKD R B N directory UM 17 For More Information www
36. ategory 2 therefore the ISR stack must be defined Add the following statement to the OS section IsrStackSize 256 4 According to the new scenario the alarm will not activate the task TASKC The alarm will set an event Cycle for the task TASKC Change the object AL1 definition according to the following pattern ALARM ALl COUNTER TaskCounter ACTION SETEVENT TASK TASKC EVENT Cycle hi OSEKturbo OS MPC5xx UM 31 For More Information www freescale com Tutorial Freescale Semiconductor Inc Using Event and Extended Task UM 32 5 To define an event for the task TASKC add the following statement to the end of appcfg oil file before closing brace for CPU Mask of the event is calculated automatically by the System Generator EVENT Cycle MASK AUTO 6 Save appcfg oil file Source Code The task TASKC will periodically call a function CycleFunc The only action of this function is to increment a variable Counter In a practical application the function can perform other actions Take the following steps to modify the application code 1 Open c userapp app2 c file in a text editor 2 Add the Counter variable declaration to the beginning of the file app2 c int Counter 3 Modify the task TASKC according to the following template TASK TASKC Counter 0 while 1 SetRelAlarm AL1 250 O0 WaitEvent Cycle CycleFunc ClearEvent Cycle
37. ation www freescale com Quick Reference Freescale Semiconductor Inc OIL Language Quick Reference Table A 7 OS Parameters Object Parameters Possible Values Description Interrupt Related Properties This group of OS attributes defines parameters of ISR execution syntax UnorderedException InterruptDispatcher The attributes should be defined inside the scope of the OS object in accordance with the following lt TRUE FALSE gt lt None OneLevel Multilevel S Enhanced gt UnorderedExceptions specific TRUE Specifies whether unordered exception handling FALSE is Supported or not InterruptDispatcher specific None OneLevel Specifies interrupt mechanism MultiLevel Enhanced Hook Routines Related Attributes This group of OS attributes defines additional hook routines support in the system syntax STARTUPHOOK SHUTDOWNHOOK PRETASKHOOK POSTTASKHOOK ERRORHOOK The attributes should be defined inside the scope of the OS object in accordance with the following lt TRUE FALSE gt lt TRUE FALSE gt lt TRUE FALSE gt lt TRUE FALSE gt lt TRUE FALSE gt USEGETSERVICEID lt TRUE FALSE gt USEPARAMETERACCESS lt TRUE FALSE gt IdleLoopHook lt TRUE FALSE gt STARTUPHOOK TRUE This standard attribute defines wheth
38. ched alarm AL1 shall be reassigned to the second timer The second timer definition shall be added to the OS section of the OIL file appcfg oil between line TargetMCU MPC555 and corresponding closing bracket below the SysTimer definition SecondTimer SWCOUNTER COUNTER TaskCounter SRPRIORITY 16 TimerHardware DEC Prescaler OS Value 0 hi TimerModuloValue 600 Freeze TRUE EF OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Tutorial TimeScale The DEC is chosen as interrupt source for the second timer The period of the timer is defined by the Prescaler setting which is controlled by the OS the tick duration is calculated by the system generator for the DEC timer with Prescaler 0 and frequency 4 MHz it is equal to 2400 microseconds 5 Add the definition of the counter which is to be attached to the system timer to the end of appcfg oil file before closing brace for CPU COUNTER SystemTimer MINCYCLE 0 MAXALLOWEDVALUE OXFFFFFFFF TICKSPERBASE 10 Correct assigned COUNTER in SysTimer definition SysTimer HWCOUNTER COUNTER SystemTimer 6 Save appcfg oil file Source Code The next step is creation of the source code for new tasks The only action of these tasks is terminating itself To activate the TimeScale the StartTimeScale service shall be executed add t
39. dler ISR SysHandler This interrupt handler is called by hardware timer on every timer tick If it is need to correct timer operation modify hardware registers here OSEKturbo OS MPC5xx UM 49 For More Information www freescale com Freescale Semiconductor Inc Using an Unsupported Target Derivatives Make File CounterTrigger SysCounter 6 Modify the vector table to support the ISR Make File It is recommended to use the makefile from the OSEK OS sample to compile an application see MakeFile The makefile has to be corrected if the application is compiled for another derivative Select the most appropriate makefile in the sample subdirectory and copy the makefile to the application directory Then correct the following parameters in the created makefile e application dependent names see MakeFile e intmembase value to map RAM according to the CPU memory map in the MEMORY part of linker script UM 50 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc A Quick Reference The appendix contains lists of OSEK OS run time services with entry and exit conditions as well as OIL object parameters with their possible values and short descriptions This appendix consists of the following sections e System Services Quick Reference e OIL Language Quick Reference System Services Quick
40. e following fields maxallowedvalue maximum possible allowed count value ticksperbase number of ticks required to reach a counter specific significant unit mincycle minimum allowed number of ticks for a cyclic alarm only for a system with Extended Status UM 58 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Quick Reference System Services Quick Reference Table A 3 Data Types Data Type Description CtrRefType The data type references a counter EventMaskRefType The data type to refer to an event mask EventMaskType The data type of an event mask FlagType The data type of a message flag ResourceType The abstract data type for referencing a resource StatusType The data type for all status information the API services offer SymbolicName A unique name representing a message TaskRefType The data type to refer variables of the TaskType data type TaskStateRefType The data type to refer variables of the TaskState Type data type TaskStateType The data type for variables to store the state of a task TaskType The abstract data type for task identification TickRefType The data type references data corresponding to the data type TickType TickType The data type represents a counter value in system ticks NOTE CtrRefType CtrlnfoType and CtrinfoRefType data types are not defined in the OSEK OS v 2 2 specification This is OSEKturbo extension o
41. ectory where System Generator common files are placed If you have installed any OSEK OS v 2 1 or Builder v 2 2 and higher before the current installation the setup program proposes to select the existing System Generator path for the SysGen root directory It is strongly recommended not to UM 8 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Installation OSEKturbo OS Installation change this path and update the existing SysGen If the System Generator has not been installed before you can select any path for the SysGen root directory c met rowerks osek by default Select components which you want to install You can choose Custom installation and select OSEK OS components which are to be installed in the Custom Installation dialog box By default all components are selected After installation verify the consistency of the package by means of comparing the real set of files and directories with the list in the filelist txt file After installation the hard drive should contain the OSEKturbo OS root directory S OSEKDIR which will contain a set of files in the following subdirectories BENCHMARK OSEKturbo OS benchmarks for performance and memory measurements BI N Platform specific part of the System Generation INC Operating System header files MAN User s Documentation PF Personality files SAMPLE OSEKturbo OS Sample applicat
42. eiveMessage OSServiceId_GetMessageResource OSServiceld_ReleaseMessageResource OSServiceld_GetMessageStatus OSServiceld_StartCOM OSServiceld_StopCOM OSServiceld_InitCOM OSServiceId_CloseCOM OSServiceId_GetAlarmBase OSServiceId_GetAlarm OSServiceld_SetRelAlarm OSServiceId_SetAbsAlarm OSServiceId_CancelAlarm e identifiers for OSEKturbo specific services OSServiceId_InitCounter OSServiceId_CounterTrigger OSServiceId_GetCounterValue OSServiceId_GetCounterInfo OSServiceId_StartTimeScale OSServiceld_StopTimeScale OSEKturbo OS MPC5xx UM 61 For More Information www freescale com Freescale Semiconductor Inc Quick Reference System Services Quick Reference e identifier returned if the error occured not in the OS service called by the user but inside OS dispatcher OSServiceId_NoService The following table contains OSEK Operating System constants with short descriptions Table A 6 OSEK OS Constants Constant Value Description RUNNING 0 Constant of data type TaskStateType for task state running WAITING 1 Constant of data type TaskStateType for task state waiting READY 2 Constant of data type TaskStateType for task state ready SUSPENDED 3 Constant of data type TaskStateType for task state suspended INVALID_TASK Constant of data type TaskType for a not defined task RES _ SCHEDULER Constant of data type ResourceType for Scheduler as a resou
43. emiconductor Inc Installation OSEKturbo OS Installation NOTE NOTE Itis important to run MWRegister on the machine where OSEKturbo shall be installed For more help on MWRegister please read MWRegister_ReadMe txt in the same directory It is strongly recommended to close all other programs and login as Administrator before installation It helps to avoid an access error during shared files and system icons installation and updating the Windows Registry It is not recommended to install the OSEKturbo OS into the directory with spaces like Program Files If the OSEKturbo OS is installed into a directory with spaces then it is not possible to use makefiles msmake bat and gnumake bat files located in SAMPLE subdirectory To use the OSEKturbo OS after installation the Cross Compiler should be installed on your computer You must call the DOS prompt under Windows 2000 98 to run the Microsoft nmake utility or GNU make utility All supplied makefiles are developed for the Microsoft C nmake and GNU make from Cygwin package v 1 3 9 utilities OSEKturbo OS Installation To setup the OSEKturbo OS on your hard drive 1 Insert the installation CD 2 Run SETUP EXE 3 Follow prompts and instructions of the installation program 4 Select directories Target Directory is a directory for OSEK source files personality files and platform specific SysGen files It is c metrowerks osek ostmpc by default Shared Components is a dir
44. er nase FALSE StartupHook is called after the operating system Sianga starting up and before the dispatcher starting or no SHUTDOWNHOOK TRUE This standard attribute defines whether Andard FALSE ShutdownHook is called during the system Sanoa shutdown or not PRETASKHOOK TRUE This standard attribute defines whether standard FALSE PreTaskHook is called from the scheduler code before the operating system enters context of the task or not POSTTASKHOOK TRUE This standard attribute defines whether the standard FALSE PostTaskHook is called from the scheduler code after the operating system leaves the context of the task or not ERRORHOOK TRUE This standard attribute defines whether the tandara FALSE ErrorHook is called by the system at the end of ae each system service which returns the status not equal to E_OK or not UM 68 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Quick Reference OIL Language Quick Reference Table A 7 OS Parameters Object Parameters Possible Values Description USEGETSERVICEID TRUE Specifies ability of usage the access macros to FALSE the service ID in the error hook standard USEPARAMETERACCESS TRUE Specifies ability of usage the access macros to FALSE the context related information in the error hook standard IdleLoopHook TRUE 4 Defines whether the IdleLoopH hook is called by i FALS
45. es GetActiveApplicationMode Current application Task ISR All hooks mode syntax AppModeType GetActiveApplicationMode void StartOS Application mode Outside of OS name syntax void StartOS AppModeType lt Mode gt ShutdownOS Error code Task ISR StartupHook ErrorHook syntax void ShutdownOS StatusType lt Error gt Hook Routines ErrorHook Error code syntax void ErrorHook StatusType lt Error gt PreTaskHook syntax void PreTaskHook void PostTaskHook syntax void PostTaskHook void StartupHook syntax void StartupHook void UM 56 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Quick Reference System Services Quick Reference Table A 1 OSEK OS Services Service Input Output Allowed In ShutdownHook Error code syntax void ShutdownHook StatusType lt Error gt IdleLoopHook syntax void IdleLoopHook void lt AlarmCallBack gt is the value of the ALARMCALLBACKNAME attribute defined in ALARM object The user can have several alarm callback functions one for each alarm defined in the OIL file lt MessageCallBack gt is the value of the CALLBACKNAME attribute defined in MESSAGE object The user can have several message callback functions one for each message defined in the OIL file NOTE InitCounter CounterTrigger G
46. etCounterValue GetCounterInfo StartTimeScale StopTimeScale GetRunningStackUsage GetStackUsage and GetTimeStamp services and IdleLoopHook hook are not defined in the OSEK OS v 2 2 specification This is OSEKturbo extension of the OSEK OS The list of macros for parameter access from ErrorHook routine is provided below Table A 2 OSEK Macros for ErrorHook Macro Return Value OSErrorGetServiceld Service identifier OSError_StartOS_Mode Application mode OSError_ActivateTask_TaskID Task identifier OSError_ChainTask_TaskID Task identifier OSError_GetTaskState_TaskID Task identifier OSError_GetResource_ResID Resource identifier OSError_ReleaseResource_ResID Resource identifier OSError_SetEvent_TaskID Task identifier OSError_GetEvent_TaskID Task identifier OSError_SendMessage_Message Message identifier OSError_ReceiveMessage_Message Message identifier OSError_GetMessageResource_Message Message identifier OSError_ReleaseMessageResource_Message OSEKturbo OS MPC5xx Message identifier UM 57 For More Information www freescale com Quick Reference Freescale Semiconductor Inc System Services Quick Reference Table A 2 OSEK Macros for ErrorHook Macro Return Value OSErrorGetServiceld Service identifier OSError_StartOS_Mode Application mode OSError_GetMessageSta
47. f the OSEK OS The list of OSEK Operating System constructional elements is provided below All declarations are dummy they are defined for compatibility with previous OSEK versions Table A 4 Constructional Elements Name Syntax DeclareTask DeclareTask lt name of task gt DeclarelSR DeclarelSR lt name of ISR gt DeclareResource DeclareResource lt name of resource gt DeclareEvent DeclareEvent lt name of event gt DeclareCounter DeclareCounter lt name of counter gt DeclareAlarm DeclareAlarm lt name of alarm gt OSEKturbo OS MPC5xx UM 59 For More Information www freescale com Freescale Semiconductor Inc Quick Reference System Services Quick Reference The table below contains all return values for the OSEK Operating System run time services and error values Table A 5 Services Return and Error Values Name Value Type E OK 0 No error successful completion E OS ACCESS 1 Access to the service object denied E OS CALLEVEL 2 Access to the service from the ISR is not permitted E OS _ID 3 The object ID is invalid E OS LIMIT 4 The limit of services objects exceeded E OS NOFUNC 5 The object is not used the service is rejected E OS RESOURCE 6 The task still occupies the resource E OS STATE 7 The state of the object is not correct for the required service E OS VALUE 8 A value outside of the admissible limit E OS SYS _ S
48. freescale com Tutorial Listing UM 43 Freescale Semiconductor Inc Tutorial Listing ACTIVATION 1 COUNTER SystemTimer MINCYCLE 0 MAXALLOWEDVALUE OXFFFFFFFF TICKSPERBASE 10 hi COUNTER TaskCounter MINCYCLE 0 MAXALLOWEDVALUE OXFFFFFFFF TICKSPERBASE 10 ALARM AL1 COUNTER TaskCounter ACTION SETEVENT TASK TASKC EVENT Cycle EVENT Cycle MASK AUTO File appl c include osprop h OS Properties file include lt osapi h gt OSEK API declarations include app h application header include lt appcfg h gt definitions for system objects int main void entry point of the application StartOS Mode jump to OSEK startup TASK TASKA task A ActivateTask TASKB Activate task TASKB TASKB priority is lower than TASKA priority Therefore TASKB transfer to ready state by ActivateTASK service TerminateTask TASKA Terminate itself TASKB will be transferred to the running UM 44 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Tutorial Listing state after terminating TASKA File app2 c finclude osprop h OS Properties file include lt osapi h gt OSEK API declarations include app h
49. his functionality to TASKC Take the following steps to modify the application code 1 Open file c userapp app2 c ina text editor 2 To define tasks TASK1 TASK2 TASK3 add the following code to the end of the file app2 c TASK TASK1 TerminateTask TASK TASK2 TerminateTask OSEKturbo OS MPC5xx UM 39 For More Information www freescale com Freescale Semiconductor Inc Tutorial TimeScale TASK TASK3 TerminateTask 3 Add call of StartTimeScale service to TASKC after ClearEvent statements according to the following template TASK TASKC Counter 0 initialize counter SetRelAlarm AL1 10 10 Set cyclic alarm WaitEvent Cycle Wait alarm AL1 expiration StartTimeScale Start Time Scale while 1 infinite loop ClearEvent Cycle Clear event WaitEvent Cycle Wait alarm AL1 expiration Call CycleFunc when alarm set event CycleFunc This line is never reached UM 40 OSEKturbo OS MPC5xx 4 Save file c userapp app2 c The tasks TASK1 TASK2 and TASK3 are activated periodically and interrupt execution of TASKA or TASKB or TASKC Running Application To execute the application take the following steps 1 Open the command prompt window change the current directory to c userapp and execute the command mk 2 Start the debugger 3 Load file c userapp
50. in this document Motorola assumes no liability to any party for any loss or damage caused by errors or omissions or by statements of any kind in this document its updates supplements or special editions whether such errors are omissions or statements resulting from negligence accident or any other cause Motorola further assumes no liability arising out of the application or use of any product or system described herein nor any liability for incidental or consequential damages arising from the use of this document Motorola disclaims all warranties regarding the information contained herein whether expressed implied or statutory including implied warranties of merchantability or fitness for a particular purpose Trademarks OSEK VDxX is a registered trademark of Siemens AG Diab D CC and SingleStep are trademarks of Wind River Systems Inc Metrowerks the Metrowerks logo and CodeWarrior are registered trademarks of Metrowerks Inc Microsoft MS DOS and Windows are trademarks of Microsoft For More Information www freescale com Freescale Semiconductor Inc Contents 1 Introduction OSEK OS Overview Technical Support Information 2 Installation Preface TE OSEKturbo OS Installation Silent Installation mode License File P OSEKturbo OS Uninstallation 3 Sample Application 4 Tutorial Source Files Building Sample Creating New Application Configuration File Source Code MakeFile Running Applicatio
51. ion SRC Operating System source files The SOSEKDIR directory contains the filelist txt file witha complete list of files included in this release and the readme txt file which provides additional information for the user After installation the hard drive should contain the root directory of the System Generator utility which will contain the following subdirectories with the System Generator and Configuration Tools files SOSEKSHARED BIN SysGen and Configuration Tools Files SOSEKSHARED TEMPLATES OSEK Builder templates The following common shared files can be updated during installation SW SW SW INSYSTEM MFC42 d11 INSYSTEM MSVCP60 d11 INSYSTEM MSVCRT d1 OSEKturbo OS MPC5xx UM 9 For More Information www freescale com Freescale Semiconductor Inc Installation OSEKturbo OS Installation These files are redistributed according to the separate License Agreement included in the Visual C version 6 0 product NOTE SOSEKDIR SOSEKSHARED and SWINSYSTEM are placeholders for the OSEKturbo OS root directory Shared Components root directory and Windows system directory names respectively They are used in this document as references to the corresponding directories Silent Installation mode In the silent installation mode there is no need for a user to monitor the setup and provide input via dialog boxes To use the installation in silent mode you should create respon
52. ivatives can have different timer structures memory map and vector table There are the following recommendations for the case if you try to use another derivative and TargetMCU is not set to MPC e If the system second timer is used check out that specified timer hardware is identical to the specified and actual derivatives Both derivatives must have the same timer structure equal timer register addresses and equal timer interrupt vector address Vector Table If TargetMCU is set to MPC the OSEK OS does not provide the vector table and the user should create a vector table corresponding to the CPU vectors To create a vector table take the following steps 1 Copy file SOSEKDIR hwspec vector c to the application directory 2 Open anew vector c file in any text editor The SOSEKDIR hwspec vector c file may be used as basis for new vector table 3 Save and close the vector c file You can find comments on using the vector c file in Source Code System Timer If another derivative is used and the TargetMCU attribute is set to MPC the OSEK OS does not provide a system timers Note that the timer s with software counter only can be added If the timer is required it should be added to the user s application The following steps describe how to implement a timer in the application code 1 Add an JSR object definition to the OIL file This ISR will be used as a system timer interrupt handler ISR
53. l or message copies are allocated by the user ResourceScheduler TRUE Specifies whether RES_ SCHEDULER should be FALSE supported or not specific UM 64 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Quick Reference OIL Language Quick Reference Table A 7 OS Parameters Object Parameters Possible Values Description CPU Related Attributes This group of OS attributes provides possibility to tune the selected hardware The attributes should be defined inside the scope of the OS object in accordance with the following syntax TargetMCU lt name of MCU gt ClockFrequency lt integer 4000 gt ClockDivider lt integer 1 gt ClockMultiplier lt integer 1 gt SysTimer lt HWCOUNTER SWCOUNTER NONE gt COUNTER lt name of COUNTER gt SRPRIORITY lt integer gt Period lt integer AUTO gt TimerHardware lt name of timer hardware gt Prescaler lt USER OS gt Value lt integer AUTO gt hy TimerModuloValue lt integer AUTO gt Freeze lt TRUE FALSE gt RTSEL lt EXTCLK OSCM gt hi SecondTimer lt HWCOUNTER SWCOUNTER NONE gt COUNTER lt name of COUNTER gt SRPRIORITY lt integer gt Period lt integer AUTO gt TimerHardware lt name of timer hardware gt Prescaler lt USER OS gt Value lt integer AUTO gt bi TimerModuloValue
54. lications and hardware platforms The OSEK OS provides a pool of different services and processing mechanisms for task management and synchronization data exchange resource management and interrupt handling The following features are granted to the user The OSEK OS is built according to the user s configuration instructions while the system is generated System and application parameters are configured statically Therefore a special tool called the System Generator is used for this purpose Special statements are designed to tune any parameter The user must only edit the definition file run the System Generator and then assemble resulting files and application files Thus the user can adapt the Operating System to the control task and the target hardware The OS cannot be modified later at execution time Technical Support Information To order Motorola Metrowerks products or literature consult your local sales representative For technical support please use US Tel 1 512 997 4700 Fax 1512 997 4901 Email support metrowerks com Europe Tel 41 61 69 07 505 Fax 41 61 69 07 501 Email support_europe metrowerks com Web _http www metrowerks com MW Support Download updates at http www metrowerks com M W Support Download UM 6 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc 2 Installation Preface The chapter contains information about the envir
55. move Programs module of the Windows Control Panel or the corresponding icon in the OSEKturbo OS MPCS5xx program folder OSEKturbo OS MPC5xx UM 11 For More Information www freescale com Freescale Semiconductor Inc Installation OSEKturbo OS Uninstallation e Delete the OSEKturbo OS root directory and all its subdirectories to delete data created during the OSEKturbo OS usage UM 12 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc 3 Sample Application The chapter presents the sample application and describes how to build the sample application This chapter consists of the following sections e Source Files e Building Sample Source Files The Sample application consists of the following source files which are placed in subdirectories of the sample standard directory e common contains derivative independent part of the sample configuration file and the source code samplets c the application code TASKSND1 TASKSND2 and TASKCNT samplerv c the application code TASKRCV1 TASKRCV2 and TASKSTOP sample h header file for the application code main oil OSEK Implementation Language file platform independent part e derivative dependent parts of the sample are located in corresponding subdirectories cfg555cw oil OSEK Implementation Language file for MPCS55 platform and CodeWarrior compiler cfg555db 0i1
56. n Additional Task Configuration File Source Code Running Application Adding Single Alarm Configuration File Source Code Running Application Using Event and Extended Task Configuration File Source Code Running Application Cyclic Alarm Source Code Running Application TimeScale OSEKturbo OS MPC5xx For More Information www freescale com an Oo nN co aN 11 11 13 13 14 17 17 17 20 22 24 26 26 27 27 28 28 29 29 30 31 32 33 34 35 36 36 UM 3 Freescale Semiconductor Inc Contents Configuration File Source Code Running Application Listing 5 Using an Unsupported Target Derivatives Target MCU Type ee ae Vector Table System Timer Make File A Quick Reference System Services Quick Reference OIL Language Quick Reference OS Object TASK Object ISR Object RESOURCE Object EVENT Object COUNTER Object ALARM Object MESSAGE Object APPMODE Object COM Object NM Object UM 4 OSEKturbo OS MPC5xx For More Information www freescale com 37 39 40 41 47 47 48 48 50 51 51 63 63 69 70 71 oar 72 3 14 75 io 76 Freescale Semiconductor Inc Introduction This User s Manual describes how to install OSEKturbo OS MPC5xx and to build sample and user s applications Information about OSEK services and OIL parameters is provided Installation chapter describes how to
57. n if such claim alleges that Motorola was negligent regarding the design or manufacture of the part Motorola and B are registered trademarks of Motorola Inc Motorola Inc is an Equal Employment Opportunity Affirmative Action Employer Legal Notices The information in this document has been carefully checked and is believed to be entirely reliable however no responsibility is assumed for inaccuracies Furthermore Motorola reserves the right to make changes to any products herein to improve reliability function or design Motorola does not assume liability arising out of the application or use of any product or circuit described herein neither does it convey any license under its patent rights or the rights of others The software described in this document is furnished under a license agreement The software may be used or copied only in accordance with the terms of the agreement No part of this publication may be reproduced or transmitted in any form or by any means graphic electronic electrical mechanical chemical including photocopying recording in any medium taping by any computer or information storage retrieval systems etc without prior permissions in writing from Motorola Inc Permission is granted to reproduce and transmit the Problem Report Form the Customer Satisfaction Survey and the Registration Form to Motorola Important Notice to Users While every effort has been made to ensure the accuracy of all information
58. n in silent mode which was created whithout installed OS then the installation will fail as there is no input saved in response file for additional dialog boxes License File If the OSEK OS package s has not been installed on your computer then the received license file should be stored on your hard disk as C flexlm license dat If the OSEK OS has been installed on your computer before the current OSEKturbo OS installation the license file has already existed on the system for the OSEK OS packages used In this case copy strings with the current OSEKturbo OS features licensed from the received license file into the existing one simply add the contents of the received file to the existing license file If you need to have the license file in another location use the LM_LICENSE_FILE environment variable to define another license file location Under Windows 2000 98 it is also possible to use the License File Manager to define non standard license file location the License File Manager is automatically installed on your PC by the OSEKturbo OS installation procedure To do this move the license file into a desired location and run the OSEKturbo OS SysGen utility The License File Manager dialog will appear providing you with a possibility to browse the license file OSEKturbo OS Uninstallation To uninstall the OSEKturbo OS e Use the UnInstall OSEKturbo OS MPCSxx v 2 2 1 Build lt build number gt item of the Add Re
59. nitions for system objects int main void entry point of the application StartOS Mode jump to OSEK startup TASK TASKA task A ActivateTask TASKB Activate task TASKB TASKB priority is lower than TASKA priority Therefore TASKB transfer to ready state by ActivateTASK service TerminateTask TASKA Terminate itself TASKB will be transferred to the running state after terminating TASKA This file contains the main function which starts the OS The TASKA code is placed in this file also TASKA activates TASKB whose priority is lower and then terminates itself UM 20 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Tutorial Creating New Application 2 Create a file app2 c in the same directory c userapp and add the following code to the file include include include include TASK TASKB osprop h OS Properties file lt osapi h gt OSEK API declarations Nano application header lt appctg h gt definitions for system objects ChaintTask TASKB TASKA TASKA state task B TASKA Chain to TASKA is terminated by this service call is activated as a chain task will be transferred to the running after TASKB termination This file contains a TASKB function This task only chains TASKA It
60. oad file c userapp bin app el1f into the debugger Set breakpoints at TASKA and TASKB functions Reset and run the application The application shall break on TASKA and TASKB by rotation a Aw A The application implements the following algorithm TASKA is autostarted by the OS This task activates TASKB which has a lower priority Then TASKA terminates itself and the OS starts TASKB activated by TASKA Then TASKB chains TASKA Therefore TASKB terminates itself and TASKA is transferred to running state It is the original position OSEKturbo OS MPC5xx UM 25 For More Information www freescale com Freescale Semiconductor Inc Tutorial Additional Task The scenario repeats endlessly The diagram of task switching sequence is shown below TASKA TASKB To clean all built files perform one of the following actions e Delete subdirectories gen obj and bin e Open the command prompt window Set the current directory to c userapp Execute nmake clean for Microsoft NMAKE utility or make clean for GNU make utility command Additional Task This section describes how to add an additional task Configuration File To add a task take the following steps 1 Open c userapp appcfg oil file in a text editor 2 To define a new task add the following statements to the end of appcfg oil file before closing brace for CPU TASK TASKC PRIORITY 3 SCHEDULE FULL AUTOSTART
61. obj If the application has more than two source files you have to add files in appsrc and appobj lists You can also leave one filename in each list if the application has one source file only 9 Change the OIL file name in the following line oilname cfg555db to oilname appcfg 10 Change the executed binary file name in the following line exename sample to exename app OSEKturbo OS MPC5xx UM 23 For More Information www freescale com Freescale Semiconductor Inc Tutorial Creating New Application 11 Create a batch file mk bat in the directory c userapp and add the following lines to the file CWDIR c metrowerks codewarrior set DIABDIR c diab set OSEKDIR c metrowerks osek osmpc set SYSGENDIR c metrowerks osek nmake Sel f Gh Gt ict Make sure that you have placed actual paths to the CodeWarrior compiler Diab Data compiler OSEK OS and SysGen directories instead of the examples you can see above If you use the GNU make utility you shall change the nmake command to the following lines set MAKE _MODE unix make Slash can be used instead of backslash in the directory names The mk bat file will be used to set the environment variables and to start operations defined in the makefile NOTE Youcan skip DIABDIR variable if you use CodeWarrior compiler only You can skip CWDIR variable if you use Diab Data compiler only Running Ap
62. on used when the SETEVENT alarm expires ALARMCALLBACK TASK name of TASK Specifies the task being notified through activation or event setting when the alarm expires EVENT name of EVENT Specifies the event mask to be set when the alarm expires It shall be defined if ACTION is SETEVENT only ALARMCALLBACKNAME _ string Specifies the name of the callback routine called when the alarm expires AUTOSTART TRUE FALSE Defines whether an alarm is started automatically at orem start up depending on the application mode ALARMTIME integer Defines the time when the alarm shall expire first CYCLETIME integer Defines the cycle time of a cyclic alarm APPMODE name of APPMODE Defines an application mode in which the alarm will be started automatically at system start up MESSAGE Object Parameters of this object type define the message properties The syntax of the message object definition is presented below Note that only one ACTION attribute should be defined for the MESSAGE object MESSAGE lt name of MESSAGE gt TYPE lt QUEUED QUEUEDEPTH CDATATYPE lt s ACTION lt ACTI TASK lt na EVENT lt n CALLBACKNAME FLAGNAME UM 74 OSE UNQUEUED gt lt integer gt tring gt me of TASK gt ame of EVENT gt lt string gt lt string gt Kturbo OS MPC5xx VATETASK SETEVENT CALLBACK FLAG NONE gt For More Information www freescale com Eg Freescale Semiconductor
63. onment required to install the OSEKturbo OS and describes installation uninstallation This chapter consists of the following sections e Preface e QSEKturbo OS Installation e License File e QSEKturbo OS Uninstallation This version of the OSEKturbo OS is to be used on an IBM PC 486 and higher compatible The PC must work under MS Windows 2000 98 during the OSEK installation The full size of the OSEKturbo OS file set is 9 MB To install the product there may be required up to 18 MB of hard disk space depending on the used file system At least 2 MB of disk space is required to run SETUP EXE About 25 MB of disk space is required for the temporary files during installation The OSEKturbo OS installation is protected with FLEXcrypt for Windows 2000 98 The OSEKturbo OS System Generator utility is protected with FLEXIm To get the installation decryption key and the license file for OSEK OS SysGen utility and TargetDLL please register Metrowerks provides a registration tool for easy registration MWRegister To register start MWRegister exe in the subfolder MWkRegister_OSEK_MPC or in the folder you have choosen during a CD installation fill out the form and press Register Select a method for registration and press OK Please provide your registration number license number if available in the form to accelerate the registration process OSEKturbo OS MPC5xx UM 7 For More Information www freescale com Freescale S
64. plication To compile the created application and execute it take the following steps 1 Open the command prompt window 2 Change the current directory to c userapp 3 Execute the command mk After the application building has been completed subdirectories gen obj and bin are placed in c userapp directory Gen includes files generated by the System Generator Obj includes object files Bin includes the executable file ORTI file and memory map If the application making has been completed successfully the following files are created in the userapp directory gen subdirectory UM 24 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Tutorial Creating New Application appcfg c system objects definition appcfg h system objects header file osprop h system properties obj subdirectory os obj osalm obj osctr obj osevt obj osisr obj osmsg obj osres obj ossch obj osset obj ostrg obj and ostsk obj OSEK OS object files appcfg obj object file for system objects appl obj and app2 obj4 application object files crts obj or __start obj start up object file vector obj initialization code and interrupt vector table object file bin subdirectory app elf executable file app map linker map of the application Some additional files such as assembler listings are also being created during the application making Start the debugger L
65. pp2 c before TerminateTask statement SetRelAlarm ALI 250 0 Running Application To execute the application take the following steps 1 Open the command prompt window change the current directory to c userapp and execute command mk 2 Start the debugger 3 Load file c userapp bin app el1f into the debugger 4 Set a breakpoint at TASKC function OSEKturbo OS MPC5xx UM 29 For More Information www freescale com Freescale Semiconductor Inc Tutorial Using Event and Extended Task 5 Reset and run the application The application will break on the task TASKC periodically 6 Add breakpoints at TASKA and TASKB functions 7 Run the application again You can see now that the task TASKC periodically interrupts the tasks TASKA and TASKB which call each other by rotation The diagram of task switching sequence is shown below TASKA TASKB TASKG A alarm AL1 period A number of TASKA TASKB activations between adjacent TASKC starts depends on CPU clock frequency and can differ from the number shown at the diagram It can happen that the TASKA TASKB execution cycle and the alarm cycle do not have a common multiple Therefore the number of TASKA and TASKB activations can vary slightly in different TASKC executions Using Event and Extended Task The periodically activated task was created in the previous section
66. rce OSMAXALLOWEDVALUE Maximum possible allowed system counter value OSMAXALLOWEDVALUE2 eM possible allowed second counter value OSTICKSPERBASE Number of ticks required to reach a counter specific value in the system counter OSTICKSPERBASE2 PSREN an ache Number of ticks required to reach a counter oitiguration OIL file specific value in the second counter OSTICKDURATION 0 Duration of the system counter tick in nanoseconds OSTICKDURATION2 Duration of the second counter tick in nanoseconds OSMINCYCLE Minimum allowed number of ticks for a ei alarm attached to the system counter only for a system with Extended Status OSMINCYCLE2 Minimum allowed number of ticks for a oyee alarm attached to the second counter only for a system with Extended Status OSDEFAULTAPPMODE Default application mode This constant is always a valid parameter for StartOS service UM 62 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Quick Reference OIL Language Quick Reference Table A 6 OSEK OS Constants Constant Value Description OsBuildNumber Current build number Constant of data type unsigned char which points to C like NULL terminated string which contains the current build number For example 2 1 1 20 NOTE OSMAXALLOWEDVALUE2 OSTICKSPERBASE2 OSTICKDURATION2 OSMINCYCLE2 and OsBuildNumber constants are not defined in the OSEK OS v 2 2 specification This is OSEK
67. s In this example we will use the HWCOUNTER with the period tick duration of 4 microsecond To configure the system timer add the following statements into the OS section of the OIL file appcfg oil between line TargetMCU MPCSS55 and ClockFrequency 4000 SysTimer HWCOUNTER COUNTER TaskCounter SRPRIORITY 8 Period 4000 hi TimerHardware TBO Prescaler OS Freeze TRUE hi UM 28 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Tutorial Adding Single Alarm The Prescaler is automatically calculated by the System Generator The timer modulo value is not used for the HWCOUNTER configuration 2 To declare a counter for the System Timer add the following statements to the end of appcfg oil file before closing brace for CPU The counter will be increased periodically on every System Timer tick COUNTER TaskCounter MINCYCLE 0 MAXALLOWEDVALUE OXFFFFFFFF TICKSPERBASE 10 3 To declare an alarm attached to the counter TaskCounter add the following statements to the end of appcfg oil file before closing brace for CPU This alarm activates the task TASKC ALARM ALl COUNTER TaskCounter ACTION ACTIVATETASK TASK TASKC hi Source Code The task TASKC code must be changed To provide the alarm setting add the following statements into the task TASKC code file c userapp a
68. scaler OS Value 0 i TimerModuloValue 600 Freeze TRUE hi hi hi TimeScale TRUE TimeUnit ms Step SET StepNumber StepTime 5 TASK TASK1 1 Step SET StepNumber 2 StepTime 2 TASK TASK2 Step SET StepNumber 3 StepTime 3 TASK TASK3 IsrStackSize 256 STARTUPHOOK FALSE SHUTDOWNHOOK FALSE PRETASKHOOK FALSE POSTTASKHOOK FALSE UM 42 OSEKturbo OS MPC5xx For More Information www freescale com ERRORHOOK Freescale Semiconductor Inc FALSE USEGETSERVICEID FALSE USEPARAME TASK TASKA TERACCESS FALSE PRIORITY 2 SCHEDULE FULL AUTOSTART TRUE ACTIVATION 1 TASK TASKB PRIORITY 1 SCHEDULE FULL AUTOSTART FALSE ACTIVATION 1 TASK TASKC PRIORITY 3 SCHEDULE FULL AUTOSTART TRUE ACTIVATION 1 STACKSIZE 256 EVENT Cycle TASK TASK1 PRIORITY 4 SCHEDULE FULL AUTOSTART FALSE ACTIVATION 1 TASK TASK2 PRIORITY 5 SCHEDULE FULL AUTOSTART FALSE ACTIVATION 1 TASK TASK3 PRIORITY 6 SCHEDULE FULL AUTOSTART FALSE OSEKturbo OS MPC5xx For More Information www
69. se file first To do so you should perform the following steps 1 Run the SETUP EXE program from the OSEKturbo OS MPC5xx installation CD with the follwing command line options setup r fl1 lt path ResponseFile gt where the r option causes Setup exe automatically to generate a silent setup file iss file which is a record of the setup input f1 specifies location and name of the response file iss file 2 Follow the prompts and instructions of the installation program to create response file to repeat actions To perform installation in silent mode you should run the SETUP EXE program from the OSEKturbo OS MPCSxx installation CD with the follwing command line options setup s f1 lt path ResponseFile gt f2 lt path LogFile gt where the r option causes SETUP EXE to execute in a silent mode f1 specifies location and name of the response file iss file f2 specifies a location and name of the log file The result of installation indicated in the log file in the ResponseResult section after the ResultCode keyname the ResultCode 0 corresponds to a successful installation UM 10 OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Installation License File NOTE Please note that installation in silent mode shall be repeated only in the same condition as the response file was created if for example you have OSEKturbo OS MPC5xx installed on your PC and then run installatio
70. t msmak directory e cw555 mak CodeWarrior compiler and MPC555 CPU e db555 mak Diab Data compiler and MPC555 CPU The Diab Data compiler and MPC555 platform were selected for the example application To tune the makefile for our new application perform the following actions 1 Copy file db555 mak from SOSEKDIR sample standard mpc555 msmak to c userapp directory 2 Rename c userapp db555 mak file to c userapp makefile 3 Open the file makefile in any text editor 4 Find the fragment beginning with the Application dependent names comment 5 Change the application directory name in the following line appdir to appdir common c userapp 6 Change the application header file name in the following line appinc to appinc S appdir sample h appdir app h OSEKturbo OS MPC5xx For More Information www freescale com NOTE Freescale Semiconductor Inc Tutorial Creating New Application 7 Change the source file names in the following lines List appsrc must enumerate all application source files appsre appdir samplesr c appdir samplepc c to appsre S appdir appl c S appdir app2 c 8 Change the object file names in the following lines List appob j must enumerate all application object files appobj S object samplesr obj S object samplepc obj to appobj S object appl obj S object app2
71. the system from the scheduler idle loop when specie there are no tasks in ready or running state or not Floating Point Related Attributes These are additional OS attributes to work with floating point Te attributes should be defined inside the scope of the OS object in accordance with the following syntax FloatingPoint lt TRUE FALSE gt FloatingPoint FALSE Turns floating point support specific TRUE NOTE The dleLoopHook hook is not defined in the OSEK OS v 2 2 specification This is OSEKturbo extension of the OSEK OS TASK Object Parameters of TASK object type define the task properties The syntax of the task object definition is as follows TASK lt name of TASK gt PRIORITY lt integer gt SCHEDULE lt FULL NON gt AUTOSTART lt TRUE FALSE gt APPMODE lt name of APPMODE gt hi ACTIVATION lt 1 gt STACKSIZE lt integer gt RESOURCE lt name of RESOURCE gt EVENT lt name of EVENT gt ACCESSOR lt SENT RECEIVED gt MESSAGE lt name of MESSAGE gt WITHOUTCOPY lt TRUE FALSE gt ACCESSNAME lt string gt OSEKturbo OS MPC5xx UM 69 For More Information www freescale com Freescale Semiconductor Inc Quick Reference OIL Language Quick Reference The brief description of the task attributes is presented below Table
72. tion cycle and the alarm cycle do not have a common multiple Therefore the number of TASKA and TASKB activations can vary slightly in different CycleFunc executions The TimeScale is OSEKturbo extension of the OSEK OS This mechanism allows the application to increase performance for set of periodic tasks activations it is a kind of a static schedule The TimeScale mechanism can be used when the sequence of task activations of reasonable size can be defined For example there are three tasks in the application TASK1 TASK2 and TASK3 each of the tasks has a period of 10 milliseconds and is executed in the following sequence TASK2 starts 5 milliseconds later OSEKturbo OS MPC5xx For More Information www freescale com Freescale Semiconductor Inc Tutorial TimeScale than TASK1 and TASK3 starts 2 milliseconds later than TASK2 This sequence of task activations repeats each the period of 10 milliseconds The TimeScale is attached to the system timer configured as HWCOUNTER and no other alarms shall be attached to it So we will configure the second timer to attach the TaskCounter The same application structure that used in the previous examples is a base for the next example Configuration File The OIL file shall be changed to add new tasks configure the TimeScale and the second timer Take the following steps 1 Open c userapp appcfg oil file in a text editor 2 Create a definition for three new tasks TASK TA
73. turbo extension of the OSEK OS OIL Language Quick Reference The lists of all the OIL object parameters with their possible values and short descriptions are provided here All standard object attributes must be always defined OSEKturbo specific attributes can be defined in addition to standard ones The value used by default is typed in boldface in the Possible Values cells Memory consumption and performance trends based on influence of individual attributes are signed in the Possible Values cells There are three signs put next to the attribute values exclude default value They display variation of RAM usage ROM usage and execution TIME first second and third sign respectively compared to the default attribute value Symbol corresponds to increasing RAM ROM or TIME Symbol corresponds to decreasing RAM ROM and TIME and symbol designates no change OS Object The OS object is the mandatory one for any application It defines the OS and its properties for the application The OS attributes exactly correspond to the system options and are divided into parts corresponding to appropriate system objects The standard and OSEKturbo specific OSEKturbo OS MPC5xx UM 63 For More Information www freescale com Quick Reference Freescale Semiconductor Inc OIL Language Quick Reference attributes of the OS object are marked by the standard and specific respectively Table A 7 OS Parameters
74. tus_Message Message identifier OSError_GetAlarmBase_AlarmID Alarm identifier OSError_GetAlarm_AlarmID Alarm identifier OSError_SetRelAlarm_AlarmID Alarm identifier OSError_SetAbsAlarm_AlarmID Alarm identifier OSError_CancelAlarm_AlarmID Alarm identifier OSError_InitCounter_CounterlD Counter identifier OSError_CounterTrigger_CounterID Counter identifier OSError_GetCounterValue_CounterlD Counter identifier OSError_GetCounterlnfo_CounterlD Counter identifier a Counter interface functions are not defined in OS sion of the OSEK OS The list of OSEK Operating EK OS v 2 2 specification this is OSEKturbo exten System Data Types is provided here Table A 3 Data Types Data Type Description AccessName A unique name defining access to a message object AccessNameRef An address of the message data field AlarmBaseRefType The data type references data corresponding to the data type AlarmBase Type AlarmBaseType The data type represents a structure for storage of alarm characteristics It is the same as CtrinfoType AlarmType The data type represents an alarm element AppModeType This data type represents the operating mode CtrinfoRefType The data type references data corresponding to the data type CtrInfoType CtrlnfoType The data type represents a structure for storage of counter characteristics This structure has th
75. utes This group of OS attributes defines stack support in the system 1 attributes should be defined inside the scope of the OS object in accordance with the following syntax IsrStackSize lt integer gt StackOverflowCheck lt TRUE FALSE gt StackOverflowCheck TRUE Turns on stack overflow runtime checking and FALS stack usage services specific Task Related Attributes This group of OS attributes controls task feature me attributes should be defined inside the scope of the OS object in accordance with the following syntax TimeScale lt TRUE FALSE gt ScalePeriod lt integer AUTO gt TimeUnit lt ticks ns us ms gt Step lt SET gt StepNumber lt integer gt StepTime lt integer gt TASK lt name of TASK gt hy TimeScale TRUE Enables Time Scale mechanism specific FALSE ScalePeriod integer Specifies full period of time scale in chosen AUTO measurement units specific TimeUnit ticks ns us ms Specifies measurement units ticks means ticks of snaiie System Timer ns means nanoseconds us P microseconds and ms milliseconds Step SET Defines one of step elements in the Time Scale specific StepNumber integer Specifies the order of steps specific StepTime integer Specifies the time until the next task activation in eee measurement units chosen by means of the pean TimeUnit attribute TASK name of TASK Specifies the task to be activated specific OSEKturbo OS MPC5xx UM 67 For More Inform

Download Pdf Manuals

image

Related Search

Related Contents

電子カタログPDF形式  ゴロカイビンク取扱説明書 ` `・`  奈良県産業会館 ハロゲン化物消火設備改修工事 仕様書 1.業務概要  Guía Técnica Neumáticos Agrícolas  世界よ、これが SAMURAI だ!  Luna™ - Billiger.de    Installation manual    ARTNIX INC., H+ DVR Series User's Guide 6.7.7 Backup  

Copyright © All rights reserved.
Failed to retrieve file