|
Interrupts and Events This chapter describes the details of interrupt and events processing in the code generated by Processor Expert. An Interrupt is a signal that causes the CPU stop the execution of the code and execute the Interrupt service routine instead. When the execution of the code is suspended, the current state of the CPU core is saved on the stack. After the execution finishes, the previous state of the CPU core is restored from the stack and the suspended program continues from the point where it was interrupted. The signals causing interrupts can be hardware events or software commands. For more details, please see an appropriate CPU manual. Processor Expert Events are part of the Embedded component interface and encapsulate the hardware or software events within the system. Events are offered by the High and Low Level components to help the user to service the events without any knowledge of the platform specific code required for such service. Processor Expert Events can be enabled and disabled and have a user-written program subroutines that are invoked when the event occurs. Events often correspond to interrupts and are for that case invoked from the generated ISR. Moreover, the event can also be a pure software event caused by a buffer overflow or improper method parameter. Interrupts Usage in Component's Generated CodeSome high-level components use interrupt service routines to provide their functionality. Usage of interrupts can usually be enabled/disabled through property "Interrupt service/event". If the interrupt service is used, complete interrupt service routine is generated into component's driver and the generated code contains configuration of the corresponding peripheral to invoke the interrupts. The user should be careful while disabling an interrupt. If a component should operate properly, it is necessary to allow the interrupt invocation by having interrupts enabled and (if the CPU contains priority system) set the corresponding interrupt priority level. This can be done using the appropriate method of the CPU component. Note: It is a common "bug" in user code, if the application is a waiting for a result of the component action while the interrupts are disabled. In this situation, the result of the component method does not change until the interrupt service routine is handled. See description of the property "Interrupt service/event" for detailed information about the particular component. Enabling EventFunctionality of each event can be enabled or disabled. The user can easily enable the event and define its name within the Component Inspector of the appropriate component. Another possibility is to double-click an event icon in the component's subtree or use a pop-up menu in the Project Panel window.
Writing an Event HandlerEvent handler is a subroutine that is assigned to a specific event. After the event is enabled Processor Expert generates the empty function of the specified name to the Event module. The user can directly open the Event handler code (if it already exists) using a Component pop-up menu > View/Edit event module or a double-click on the event within the Project Panel. The event handler is an ordinary function and the user needs not to provide the interrupt handling specific code in his/her event code. Interrupt Service RoutinesWhen High or Low-level components are used, the interrupts functionality is covered by the events of the components. The interrupt subroutines calling the user's event handlers are generated to the component modules and PE provides parts of the background code necessary to correctly handle the interrupt requests. The Peripheral Initialization components can only provide the initialization of the interrupt and generate a record to the Interrupt Vector Table. The user has to provide a full implementation of the interrupt subroutine. See chapter Typical Peripheral Initialization Components Usage for details. Copyright 2013 Freescale Semiconductor, Inc.
PROCESSOR EXPERT is trademark of Freescale Semiconductor, Inc. |