Processor Expert Guide
Processor Expert Guide
Processor Expert Guide
Processor Expert
User Guide
Freescale, the Freescale logo, CodeWarrior, ColdFire, Kinetis, and Processor Expert are trademarks of Freescale Semiconductor, Inc.,Reg. U.S. Pat. & Tm. Off. Flexis and Processor Expert are trademarks of Freescale Semiconductor, Inc.
The Power Architecture and Power.org word marks and the Power and Power.org logos and related marks are trademarks and service marks licensed by Power.org. All other product or service names are the property of their respective
owners.
2011-2014 Freescale Semiconductor, Inc. All rights reserved.
Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductor products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document.
Freescale Semiconductor reserves the right to make changes without further notice to any products herein. Freescale
Semiconductor makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does Freescale Semiconductor assume any liability arising out of the application or use of any product
or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. Typical parameters that may be provided in Freescale Semiconductor data sheets and/or specifications can and
do vary in different applications and actual performance may vary over time. All operating parameters, including Typicals, must be validated for each customer application by customer's technical experts. Freescale Semiconductor does
not convey any license under its patent rights nor the rights of others. Freescale Semiconductor 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 Freescale Semiconductor product could create a situation where personal injury or death may occur. Should Buyer purchase or use
Freescale Semiconductor products for any such unintended or unauthorized application, Buyer shall indemnify and hold
Freescale Semiconductor 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, even if such claim alleges that Freescale
Semiconductor was negligent regarding the design or manufacture of the part.
How to Contact Us
Corporate Headquarters
http://www.freescale.com/codewarrior
Technical Support
http://www.freescale.com/support
Table of Contents
1
Introduction
Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Features of Processor Expert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Key Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Advantages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Embedded Components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Creating Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
RTOS Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Terms and Definitions Used in Processor Expert . . . . . . . . . . . . . . . . . . . . . . . . 15
User Interface
19
Main Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Project Pop-up Menu. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Processor Expert Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Components View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
View Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Pop-up Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Components Library View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Pop-up Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Component Assistant. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Component Inspector View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Read Only Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
View Mode Buttons. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
View Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Pop-up Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Inspector Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Items Visibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Pin Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Component Inspector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Table of Contents
Application Design
51
Table of Contents
141
Table of Contents
Index
149
1
Introduction
Processor Expert (PE) is designed for rapid application development of embedded
applications for a wide range of microcontrollers and microprocessor systems.
This chapter explains:
Overview
Features of Processor Expert
Concepts
Terms and Definitions Used in Processor Expert
Overview
Processor Expert provides an efficient development environment for rapid application
development of the embedded applications. You can develop embedded applications for a
wide range of microcontrollers and microprocessor systems using Processor Expert.
Processor Expert is integrated as a plug-in into the Eclipse IDE. You can access Processor
Expert from the IDE using the Processor Expert menu in the IDE menu bar. The Processor
Expert plug-in generates code from the embedded components and the IDE manages the
project files, and compilation and debug processes.
The figure below shows the Processor Expert menu in the IDE menu bar.
Introduction
Features of Processor Expert
Figure 1.1 IDE with Processor Expert Menu
NOTE
For more information about how to create a new project, refer to the Processor
Expert Tutorials chapter or Creating Application using Processor Expert
chapter for step-by-step instructions on how to create a new Processor Expert
project.
NOTE
Processor Expert generates all drivers during the code generation process. The
generated files are automatically inserted into the active (default) target in the
project. For more information on generated files, refer to the Code Generation
chapter.
Introduction
Features of Processor Expert
Processor Expert connects, and generates the drivers for embedded system hardware,
peripherals, or used algorithms. This allows you to concentrate on the creative part of
the whole design process.
Processor Expert allows true top-down style of application design. You can start the
design directly by defining the application behavior.
Processor Expert works with an extensible components library of supported
microprocessors, peripherals, and virtual devices.
Processor Expert peripheral initialization components generate effective
initialization code for all on-chip devices and support all their features.
Logical Device Drivers (LDD components) are efficient set of embedded
components that are used together with RTOS. They provide a unified hardware
access across Microcontrollers allowing to develop simpler and more portable RTOS
drivers or bare board application. For more details, refer to the Logical Device
Drivers topic.
Processor Expert allows to examine the relationship between the embedded
component setup and control registers initialization.
An intuitive and powerful user interface allows you to define the system behavior in
several steps. A simple system can be created by selecting the necessary components,
setting their properties to the required values and also dragging and dropping some of their
methods to the user part of the project source code.
The other key features are:
Design-time verifications
Microcontroller selection from multiple Microcontroller derivatives available
Microcontroller pin detailed description and structure viewing
Configuration of functions and settings for the selected Microcontroller and its
peripherals
Definition of system behavior during initialization and at runtime
Design of application from pre-built functional components
Design of application using component methods (user callable functions) and events
(templates for user written code to process events, e.g. interrupts)
Customization of components and definition of new components
Tested drivers
Library of components for typical functions (including virtual SW components)
Verified reusable components allowing inheritance
Verification of resource and timing contentions
Concept of project panel with ability to switch/port between Microcontroller family
derivatives
Processor Expert User Guide
Introduction
Features of Processor Expert
Code generation for components included in the project
Implementation of user written code
Interface with Freescale CodeWarrior
This section includes the following topics:
Key Components
Advantages
Key Components
The key components are:
Graphical IDE
Built-in detailed design specifications of the Freescale devices
Code generator
Advantages
PE based tool solution offers the following advantages to Freescale Microcontroller
customers:
In all phases of development, customers will experience substantial reductions in
development cost
development time
Additional benefits in product development process are:
Integrated Development Environment Increases Productivity
Minimize Time to Learn Microcontroller
Rapid Development of Entire Applications
Modular and Reusable Functions
Easy to Modify and Port Implementations
10
Introduction
Features of Processor Expert
design phase. Processor Expert justifies its existence even when used for this purpose
alone.
This system frees you up from the hardware considerations and allows you to
concentrate on software issues and resolve them.
It is good for processors with embedded peripherals. It significantly reduces project
development time.
The primary reasons why you should use Processor Expert are:
Processor Expert has built-in knowledge (internal definition) of the entire
microcontroller with all its integrated peripherals.
Processor Expert encapsulates functional capabilities of microcontroller elements
into concepts of configurable components.
Processor Expert provides an intuitive graphical user interface, displays the
microcontroller structure, and allows you to take the advantage of predefined and
already verified components supporting all typically used functions of the
microcontroller.
Applications are designed by defining the desired behavior using the component
settings, drag and drop selections, utilizing the generated methods and events
subroutines, and combining the generated code with user code.
Processor Expert verifies the design based on actual microcontroller resource and
timing contentions.
Processor Expert allows the efficient use of the microcontroller and its peripherals
and building of portable solutions on a highly productive development platform.
11
Introduction
Features of Processor Expert
12
Introduction
Concepts
Concepts
The main task of Processor Expert is to manage processor and other hardware resources
and to allow virtual prototyping and design.
Code generation from components, the ability to maintain user and generated code, and an
event based structure significantly reduce the programming effort in comparison with
classic tools.
This section covers the following topics:
Embedded Components
Creating Applications
RTOS Support
Embedded Components
Component is the essential encapsulation of functionality. For instance, the TimerInt
component encapsulates all processor resources that provide timing and hardware
interrupts on the processor.
Figure 1.2 Example of TimerInt Component (Periodical Event Timer) Properties
You will find many components that are called embedded components in the Processor
Expert Components library window. These components are designed to cover the most
commonly required functionality used for the microcontroller applications, such as from
handling port bit operations, external interrupts, and timer modes up to serial
asynchronous/synchronous communications, A/D converter, I2C, and CAN.
By setting properties, you can define the behavior of the component in runtime. You can
control properties in design time by using the Component Inspector. Runtime control of
the component function is done by the methods. Events are interfacing hardware or
software events invoked by the component to the user's code.
You can enable or disable the appearance (and availability) of methods of the component
in generated source code. Disabling unused methods could make the generated code
shorter. For more details, refer to the General Optimizations topic.
13
Introduction
Concepts
Events, if used, can be raised by interrupt from the hardware resource such as timer, SIO
or by software reason, such as overflow in application runtime. You can enable or disable
interrupts using component methods and define priority for event occurrence and for
executing its Interrupt Service Routine (ISR). The hardware ISR provided by the
component handles the reason for the interrupt. If the interrupt vector is shared by two (or
more) resources, then this ISR provides the resource identification and you are notified by
calling the user event handling code.
Creating Applications
Creation of an application with Processor Expert on any microcontroller is fast. To create
an application, first choose and set up a processor component, add other components,
modify their properties, define events and generate code. Processor Expert generates all
code (well commented) from components according to your settings. For more details,
refer to the Code Generation topic.
This is only part of the application code that was created by the Processor Expert
processor knowledge system and solution bank. The solution bank is created from hand
written and tested code optimized for efficiency. These solutions are selected and
configured in the code generation process.
Enter your code for the events, provide main code, add existing source code and build the
application using classic tools, such as compiler, assembler and debug it. These are the
typical steps while working with Processor Expert.
Other components may help you to include pictures, files, sounds, and string lists in your
application.
Processor Expert has built-in knowledge (internal definitions) about the entire
microcontroller with all integrated peripherals. The microcontroller units and peripherals
are encapsulated into configurable components called embedded components and the
configuration is fast and easy using a graphical Component Inspector.
Peripheral Initialization components are a subset of embedded components that allow you
to setup initialization of the particular on-chip device to any possible mode of operation.
You can easily view all initialization values of the microcontroller produced by Processor
Expert with highlighted differences between the last and current properties settings.
Processor Experts performs a design time checking of the settings of all components and
report errors and warnings notifying you about wrong property values or conflicts in the
settings with other components in the project. For more information, refer to the Design
Time Checking: Consequences and Benefits topic.
Processor Expert contains many useful tools for exploring a structure of the target
microcontroller showing the details about the allocated on-chip peripherals and pins.
Processor Expert generates a ready-to-use source code initializing all on-chip peripherals
used by the component according to the component setup.
14
Introduction
Terms and Definitions Used in Processor Expert
RTOS Support
Processor Expert provides a set of LDD components (Logical Device Drivers) that support
generation of driver code that can be integrated with RTOSes (Real Time Operating
Systems). For more details, refer to the Logical Device Drivers topic.
15
Introduction
Terms and Definitions Used in Processor Expert
microcontroller supported by the Processor Expert. They provide methods and events for
runtime control. For details, refer to the Component Categories topic.
Internal peripherals internal devices of the microcontroller such as ports, timers, A/D
converters, etc. usually controlled by the processor core using special registers.
ISR - Interrupt Service Routine code which is called when an interrupt occurs.
LDD components Logical Device Driver components. The LDD components are
efficient set of components that are ready to be used together with RTOS. They provide a
unified hardware access across microcontrollers allowing to develop simpler and more
portable RTOS drivers. For details, refer to the Component Categories topic.
Low level component a component dependent on the peripheral structure to allow the
user to benefit from the non-standard features of a peripheral. The level of portability is
decreased because of this peripheral dependency. For details, refer to the Component
Categories topic.
Microcontroller - Microcontroller Unit microcontroller used in our application.
Methods user callable functions or sub-routines. The user can select which of them
will be generated and which not. Selected methods will be generated during the code
generation process into the component modules.
Module - Source code module could be generated by Processor Expert (Component
modules, Processor Module, events.c) or created by the user and included in the project
(user module).
OOP Object-oriented programming (OOP) was invented to solve certain problems of
modularity and reusability that occur when traditional programming languages such as C
are used to write applications.
PE Abbreviation of Processor Expert that is often used within this documentation.
PESL Processor Expert System Library (PESL) is dedicated to power programmers,
who are familiar with microcontroller architecture - each bit and each register. PESL
provides the macros to access the peripherals directly, so PESL should be used only in
some special cases. For details, refer to the Processor Expert System Library topic.
Peripheral Initialization component encapsulates the whole initialization of the
appropriate peripheral. Components that have the lowest levels of abstraction and usage
comfort. For details, refer to the Component Categories topic. They usually do not support
any methods or events except the initialization method. The rest of the device driver code
needs to be written by hand using either PESL or direct control of the peripheral registers.
For details, refer to the Low-level Access to Peripherals topic.
Popup menu this menu is displayed when the right mouse button is pressed on some
graphical object.
PLL Phase Locked Loop. This circuit is often built-in inside the processor and can be
used a main source of the clock within the processor.
16
Introduction
Terms and Definitions Used in Processor Expert
Prescaler A fixed or configurable device that allows to divide or multiply a clock
signal for a peripheral processor peripheral or its part.
Properties Parameters of the component. Property settings define which internal
peripherals will be used by the component and also initialization and behavior of the
component at runtime.
RTOS Real Time Operating System is an operating system (OS) intended for real-time
applications.
Processor The processor derivative used in a given project.
Template It is a component template with preset parameters.
User-defined Component Template User-defined component template is a
component with preset parameters saved under a selected name. Also the name of the
author and short description can be added to the template.
User module Source code module created or modified by the user. (Main module,
event module or external user module).
Xtal A crystal - a passive component used as a part of an oscillator circuit.
17
Introduction
Terms and Definitions Used in Processor Expert
18
2
User Interface
The Processor Expert menu is integrated as a plugin in the Eclipse IDE providing set of
views. The IDE main menu has a menu item named Processor Expert.
The user interface of Processor Expert consists of the following windows:
Component Inspector Allows you to setup components of the project.
Component Library Shows all supported components including processor
components and component templates.
Configuration Registers Shows overview of the peripheral initialization
settings for the current processor.
Memory Map Shows the processor address space and internal and external
memory mapping.
Components Shows an embedded component that can be used in Processor
Expert.
Initialization Sequence It is possible to customize the initialization sequence of
components. By default, the sequence is not specified. You can change the
sequence using up or down buttons. Initialization of processor component is
always first.
Processor The processor derivative used in a given project.
This chapter explains:
Main Menu
Components View
Components Library View
Component Inspector View
Processor View
Memory Map View
Configuration Registers View
Initialization Sequence View
19
User Interface
Main Menu
Main Menu
The Processor Expert plug-in is integrated into the Eclipse IDE as plugin application. The
IDE main menu contains a new menu item named Processor Expert.
The Processor Expert menu includes:
Show views Shows standard Processor Expert windows in case they are hidden.
Hide views Hides Processor Expert views.
Import Components(s) This command allows to select and install Processor
Expert update packages (.PEUpd) files. These files can be created in Component
Development Environment (CDE) by exporting a user's component.
Project Options
Project options related to Processor Expert can be found in Properties dialog box. To
access this dialog box, click Project > Properties. The Properties dialog box appears.
Select Processor Expert option in the list on the left. Description of the individual options
can be found in the hint window displayed when the cursor is placed on an item.
20
User Interface
Main Menu
Figure 2.1 Project Properties Dialog
NOTE
Restore Defaults button restore all settings to its default values except Code
Generation reference number. This number indicates number of times code
was generated for a given project.
Preferences
Global settings related to Processor Expert can be found in Preferences dialog available
using the command Window > Preferences. The PE related items can be found under
Processor Expert in the list on the left. Description of the individual options can be found
in the hint window displayed when the cursor is placed on an item.
21
User Interface
Main Menu
Figure 2.2 Preferences Dialog
There is an option Preferred inspector views that allows you to decide how to display the
tabs of Component Inspector view. The three views are Custom, Classic, and Tabs.
To start or shutdown the processor expert, click Windows > Preferences and expand
General and select Startup and Shutdown.
Processor Expert starts after the Eclipse workbench user interface is displayed if the
Processor Expert Core checkbox is selected as shown below.
22
User Interface
Components View
Figure 2.3 Preferences Startup and Shutdown
Components View
Components view shows the tree with the following items:
Generator_Configurations Configurations of the project.
Operating System contains special components that provide operating system
interface and configuration if there are any used.
Processors contains Processor Components included in the project.
Components it is included in the project. Every component inserted in the project
is displayed in the Component Inspector view and may have a sub tree showing
items available for the component (note that components can offer only some or even
none of these items):
Methods Methods allow runtime control of the component's functionality.
Events routines Events allow handling of the hardware or software events
related to the component. If the event is disabled, the name of the event is shown.
For enabled events, the name of the handling function is shown.
23
User Interface
Components View
ISRs Represent component-related interrupt routines that is created by you for
low-level interrupt processing. For items, whose ISR names have been specified
within component settings, a user-specified name of an ISR and name of the
interrupt vector is shown. If an ISR name is not specified (interrupt has to be
disabled in this case), only the interrupt vector name is present.
You can specify an ISR in the component and generate the code. If the Generate
ISRs project option is selected, empty ISR templates are generated into an event
module. If you disable an ISR and select the Delete unused events and ISRs
project option, empty ISR templates are removed automatically.
PESL commands low-level PESL commands related to the peripheral
configured by this component. This folder is available only for Peripheral
Initialization components.
PDD Macros low-level PDD macros for peripherals allocated by the
component. Macros can be dragged and dropped into the source code. If the PDD
macro is dragged, the base address parameter is automatically filled with the
macro-value which uses the peripheral selected in the component.
NOTE
PESL and PDD folders are available only for Peripheral Initialization
components and only if PDD library or PESL library is supported for the
selected processor. Either PESL or PDD folder is displayed and not both.
PDD The global list of all PDD macros for all available peripherals are grouped
by peripheral name. This folder is available only if PDD is available for the currently
active CPU. PDD commands are low-level peripheral access macros and they are the
replacement of PESL macros. PDD commands are available on all platforms
supported by Logical Device Drivers (LDD). Macros can be dragged and dropped
into the source code. For details on PDD, refer to the Low-level Access to
Peripherals topic.
24
User Interface
Components View
Figure 2.4 List of PDD Macros
All component's items have status icons that signify the enabled or disabled state. If this
state cannot be changed directly, the background of the icon is gray. For more details,
refer to the Embedded Components topic.
Shared components are automatically placed into a dedicated subfolder
Referenced_Components. You can move the component from this folder to anywhere.
This table explains the various states of a component.
Table 2.1 Description of Component States
Component Status Icon
Description
Signifies that component is enabled. It can
be configured and code can be generated
from this component.
Signifies that component is disabled. It can
be configured, but the configuration
validation/ generation is disabled. No code is
generated from this component.
Signifies error in the component. For
example, Components folder contains
component with error.
Signifies that component is frozen and will
not be re-generated. When the user
generates the code again, files of this
component are not modified and the
generated code is frozen.
25
User Interface
Components View
Figure 2.5 Referenced Components
When you have more than one Processor Expert project in your workspace and you are
working with those projects, the last project shown in Components view is recorded in
the workspace history. When you restart the Eclipse IDE, the last session project is opened
automatically.
View Menu
Generate Processor Expert Code invokes code generation for the current
project.
Synchronize Processor Expert Static Code forces static code synchronization.
For details, refer to the Static Code Support in Processor Expert topic.
Close/Open Processor Expert Project closes the project if it is open or opens the
project if it is closed.
Properties displays the Processor Expert properties for a specific project.
Edit Initialization Sequence modify the initialization sequence of components.
Export allows to export component settings or configuration of selected
Processor Expert components.
Import allows to import component settings or configuration of selected
Processor Expert components.
Pop-up Menu
Inspector opens Component Inspector view for the component. For more
details, refer to the Component Inspector View topic.
Inspector - Pinned opens Component Inspector view for the component in
"pinned" mode. This command allows to have several inspector views for different
26
User Interface
Components View
components opened at once. For more details, refer to the Component Inspector
View topic.
Code Generation allows to disable/enable the generated module for the
component.
Configuration Registers displays the Configuration Registers view for the
peripheral initialized by the selected component. For more details, refer to the
Configuration Registers View topic.
Target Processor Package displays the Processor view for the processor
derivative used in a given project.
Processor Memory Map displays the Memory Map view for the processor
address space and internal and external memory mapping.
Rename Component changes the name of the component.
Select Distinct/Shared mode switches between shared and distinct mode of the
component. This setting is available for LDD components only. For more details,
refer to the Logical Device Drivers topic.
Open File opens the generated code from the selected component for the source
code editor. Note that the code is available only after successful code generation.
Component Enabled enables/disables component in the project.
Remove component from project deletes the component from the project.
Help on component shows a help page for the component.
Save Component Settings As Template creates a template of the selected
component. For more details, refer to the Creating User Component Templates topic.
View Code Opens code editor at the code of the selected method or event.
Toggle Enable/Disable Enables/Disables the Method or Event.
Figure 2.6 Components View
27
User Interface
Components Library View
Modes
The Components Library has the following four tabs allowing you to select components in
different modes:
Categories Contains all available components. The components are sorted in a
tree based on the categories defined in the components. For more details, refer to the
Component Categories topic.
Alphabetical Shows alphabetical list of the available components.
Assistant Guides you during the component selection process. The user answers a
series of questions that finally lead to a selection of a component that suits best for a
required function. For more details, refer to the Component Assistant topic.
Processors Contains list of the available processors.
Component names are colored black and the component template names are colored blue.
The components that are not supported for the currently selected target processor are gray.
By double-clicking on the component, it is possible to insert the component into the
current project. The description of the component is shown in a hint.
Filtering
Filter can be activated using the filtering icon. If it is active, only the components that
could be used with the currently selected target processors are shown.
If the filter is inactive, Processor Expert also shows components that are not available for
the current processor.
Pop-up Menu
A pop-up menu opens by right-clicking a component or folder. It contains the following
commands:
Add to project Adds the component to the current project.
Add to project with wizard Adds the component to the current project and opens
a configuration wizard.
Expand all Expands the folder and all its subfolders.
Collapse all Collapses the folder and all its subfolders.
28
User Interface
Components Library View
Refresh Refreshes the view area.
Delete Only user templates and components are deleted. User component is
deleted from the folder <Processor Expert Install>/
ProcessorExpert/Beans/<ComponentToBeDeleted>. Other files like
*.inc, *.drv, *.src remain intact.
Help on component Opens help information for the selected component.
Figure 2.7 Components Library
Component Assistant
The Component Assistant is a mode of Components Library view. It guides you during
the selection of components, that is basic application building blocks. You will have to
answer a series of questions that finally lead to a selection of a component that suits best
for a required function. In this mode, the Components Library view consists of the
following parts:
History navigation buttons and the history line showing answers for already
answered questions. You can walk through the history using the arrow buttons or by
clicking the individual items.
A box with a current question.
A list of available answers for the current question.
If the answer already corresponds to a single component (it has an icon of the
component and there is a [component name] at the end of the list line) and user
double-clicks it, it is added into the project. Also, you can right-click on the line to
open the pop-up menu of the component, allowing to add it into the project or view
its documentation (for details, refer to the Components Library View topic).
29
User Interface
Component Inspector View
If more questions are necessary for the component selection, the line with the answer
contains a group icon and in brackets a number of components that still can possibly
be selected. After clicking on such line a next question is displayed.
This mode of Components Library does not offer addition of processor components. If
you would like to add another processor component, switch to processors tab.
The Component Inspector can be displayed in three views. The views can be selected from
the Preferences dialog. On the left side of the Preferences dialog, select Processor
Expert > General. On the right side, select Preferred inspector views from the dropdown list as shown below.
30
User Interface
Component Inspector View
Figure 2.9 Preferred inspector views
31
User Interface
Component Inspector View
Figure 2.10 Tabs View
NOTE
After selecting the required view, restart or switch the workspace to display the
selected view in Component Inspector.
In the Preferences dialog, you can also choose the number of columns that will appear in
Component Inspector view for displaying properties. Select Inspector columns count
and choose the value from 1 to 4 from the drop-down list. This option is valid only for
Tabs view.
You can filter pin names in the Component Inspector view. It is now easy to select pin
from the long drop- down list. You can type the text and filter list of available values. The
filtering is enabled only when more than 3 values are available in the list.
Figure 2.11 Filtering Pin Names
32
User Interface
Component Inspector View
View Menu
This menu can be invoked by clicking on the down arrow icon. The menu contains the
following commands:
Basic, Advanced view mode switching. These options have the same meaning as
the view mode buttons.
Ignore Constraints and non-Critical Errors this option enables a special mode
of Processor Expert. In this mode, Processor Expert allows you to generate output
files, even though some settings may break some constraints or limits and errors are
reported.
Expand All if a group is selected, expands all items within the selected group.
Otherwise, all groups in the Inspector are expanded. If the expanded group contains
any groups that are disabled (gray), the user is asked if the disabled groups should all
be expanded.
Collapse All if a group is selected, collapses all items within the selected group.
Otherwise, all groups in the Inspector are collapsed.
Help on Component shows a help page for the component.
Save component settings as template creates a template for the current
component settings. Refer to the Creating User Component Templates topic for
details.
Edit comment when comment is empty, icon appears gray. If you have entered
the comment, icon appears yellow on the toolbar. The comment is displayed in
tooltip for the current component or configuration. For example, you can enter the
note for the CPU component, such as "Please do not enter value more than 25MHz in
Clock settings." These comments are added in the generated source file, Cpu.h file.
Open New pinned view opens a copy of the inspector for currently selected
component. This command allows to have several inspector views for different
components opened at once.
33
User Interface
Component Inspector View
Tabs view this view displays configuration elements in graphical form, better
organized, easy to understand and use. Nested tabs and tables are used to present
complex configurations.
Search searches Inspector item by name. It also accepts wild cards like * or ? (*
=any string and ? = any character).
Pop-up Menu
This menu is invoked by right-clicking a specific inspector item. The menu contains the
following commands:
Figure 2.12 Component Inspector View Pop-up Menu
Expand All if a group is selected, expands all items within the selected group.
Otherwise, all groups in the inspector are expanded. If the expanded group contains
any groups that are disabled (gray), the user is asked if the disabled groups should all
be expanded.
Collapse All if a group is selected, collapses all items within the selected group.
Otherwise, all groups in the inspector are collapsed.
Help on Component shows a help page for the component.
Pin Sharing Enabled enables the pin sharing. This command is available only
for pin properties. For more information, refer to the Pin Sharing topic.
Move Item Up moves the item up in the list.
Move Item Down moves the item down in the list.
Move Item Top moves the item on the top of the list.
Move Item Bottom moves the item at the bottom of the list.
NOTE
34
User Interface
Component Inspector View
Delete Item does not delete the component, but can delete the property item from
the list of property. The list of items can have some constraints on minimal or
maximum number of items. Add ADC component into the project and add at least
one extra channel then you will be able to see this option enabled.
Inspector Items
The following types of the items are there in the Component Inspector view.
Figure 2.13 Example Component with Various Inspector Item Types
35
User Interface
Component Inspector View
Table 2.2 explains the various types of items.
Table 2.2 Inspector Item Types
36
Field
Description
Boolean Group
Boolean yes/no
Enumeration
Enumeration Group
File/Directory Selection
Group
User Interface
Component Inspector View
Table 2.2 Inspector Item Types
Field
Description
Integer Number
List of items
Peripheral selection
Real Number
37
User Interface
Component Inspector View
Table 2.2 Inspector Item Types
Field
Description
String
String list
Time, Date
Timing settings
Items Visibility
Processor Expert supports selectable visibility of the component items. Each item is
assigned a predefined level of visibility. Higher visibility level means that items with this
level are more special and rarely used than the others with the lower visibility level.
Component Inspector displays only items on and below the selected level. It could help
especially beginners to set only basic properties at first and do optimization and
improvements using advanced and expert properties or events later. There are three
visibility levels:
Basic view The key and most often used items that configure the basic
functionality of the components.
38
User Interface
Component Inspector View
Advanced view All items from Basic view and the settings that configure some
of more advanced and complex features of the component.
The visibility can be switched in the Component Inspector using Basic and Advanced
buttons or within its view menu.
NOTE
If an error occurs in a property with a higher visibility level than the level
currently selected, then also this error is displayed.
Pin Settings
New pin model in Processor Expert is currently supported for Vybrid derivative. It allows
to specify requirements for the pin configuration from different components. By default,
property for pin selection contains Automatic value which represents no requirement for
the configuration. If there is no requirement from the property:
If there are requirement for pin assignment from another component, this pin is used
If there are no requirements from any component, default assigned pin is used
If there is no default assigned pin or the default assigned pin is in conflict with
another configuration, no pin is assigned to the property
The requirements for pin configuration is specified from several components. Duplicated
requirements does not represent any conflict and are accepted.
PinSettings component allows to specify pin configuration for all pins of the processor.
You have the choice to specify pin routing either in PinSettings component or directly in
LDD components (or both).
For automotive applications, it is expected that HW designer specify pin (pin routing)
during board design (HW perspective is used) and sends it to SW engineers as an input for
configuration of the SW application.
Component Inspector
Component Inspector is one of the inspector view variants intended to configure
component settings. It allows to setup Properties, Methods, and Events of a component.
Use command Help on Component from View menu (invoked by the down arrow icon)
to see documentation for currently opened component.
NOTE
Property settings influencing the hardware can often be better presented by the
processor package view using the Processor view. Refer to the Processor View
topic for details.
39
User Interface
Component Inspector View
Figure 2.14 Component Inspector View
The Build options page is present only in the processor component and it provides access
to the settings related to linker and compiler.
The Resources page shows list of the processor component resources. You can also
manually block individual resources for using them in Processor Expert.
The page consists of the three columns:
First shows the name of the resource. Resources are in groups according to which
device they belong to.
Second column allows you to reserve resource (for example pin) for external
module. Click on icon to reserve/free a resource. Reserved resource is not used in
Processor expert any more.
Third column shows the current status of the resource and the name of the
component which uses it (if the resource is already used).
For more details on component inspector items, refer to the Dialog Box for Timing
Settings and Syntax for the Timing Setup in the Component Inspector topic.
In the Component Inspector view, you can view the clock diagram for only vybrid
derivative. Create a project with Vybrid MVF50GS10xx derivative and add some
peripheral initialization components, for example, Init_FTM. See the Clock Diagram
tab in the Inspector view.
40
User Interface
Component Inspector View
Figure 2.15 Inspector View Clock Diagram
41
User Interface
Component Inspector View
Figure 2.19 Switch
42
User Interface
Component Inspector View
Clock consumer or peripheral
Figure 2.24 Clock Consumer
43
User Interface
Component Inspector View
Figure 2.25 Timing Settings Dialog Box
Runtime setting determines how the timing setting can be modified at runtime. The
following options available are:
fixed value Timing cannot be changed at runtime.
from a list of values Allows to change the timing by selecting one of predefined
values (from the list) using component method "SetXXXMode". This method sets
the value(s) corresponding to the selected timing into the appropriate prescaler and
other peripheral register(s). The values (modes) in the list can be added/removed by
editing the timing values table.
44
User Interface
Component Inspector View
from interval Allows to change a timing freely within a selected interval, while
all values of the interval are selected with specified precision. Prescaler value is fixed
in this mode, timing is set only using compare/reload registers value. It means that it
is possible to reach all values within the interval by using the same prescaler.
Note that this kind of runtime setting requires runtime computations that can be time and
space consuming and may not be supported on all microcontrollers.
NOTE
Some of the methods used for runtime setting of timing will be enabled only if
the appropriate runtime setting type is selected.
45
User Interface
Component Inspector View
In case of interval settings type, the % of low limit (percentage of the low limit value) can
be used as the unit for this value.
It represents requirement for minimal number of timer ticks for specified period (usually it
affects minimal value set into reload or modulo register). This is useful for configurations
where it is expected to change period or duty in runtime, and in this case the parameter
affects supported scale for such changes. There will be guarateed that there will be at least
the given number of distinct values available for adjusting the duty of output signal. This
will also be guaranteed for any available period of the signal.
Adjusted Values
This table displays real values for each speed mode of the selected row in the Timing
values table.
These values are computed from the chosen on-chip peripheral settings, selected
prescaler(s) value and the difference between a value selected by the user and the real
value.
Status Box
The status box displays a status of the timing setting(s). If the timing requirements are
impossible to meet, a red error message is displayed, otherwise it is blank and gray.
46
User Interface
Component Inspector View
Timing unit If a frequency unit is used (for example, Hz, kHz), the step column is
not visible.
By clicking on the table header, there is possible to order the rows as per selected column.
By clicking the same column again, you can arrange the rows in ascending or descending
order.
Double-clicking on a value will place the value into the currently edited row within the
Timing values table.
The values listed in the possible settings table depend on the following timing settings:
prescalers
minimal timer ticks
and it also depends on
selected processor
selected peripheral
speed-modes enabled for the component
The table contains a speed mode tabs (speed modes and related settings are supported
only in the Expert view mode) that allow to filter the displayed intervals for a specific
speed mode or show intersection of all. Note that the intersection contains only values that
can be set in all speed modes with absolute precision (without any error), so some values
that are still valid, but due to non-zero Error allowed, values are not shown.
47
User Interface
Component Inspector View
Hertz A value must be followed by Hz.
kilohertz A value must be followed by kHz.
megahertz A value must be followed by MHz.
bit/second A value must be followed by bits.
kbit/second A value must be followed by kbits.
For example, if you want to specify 100 milliseconds, enter 100 ms.
For more details on timing configuration, refer to the Timing Settings topic.
Configuration Inspector
Configuration Inspector is a variant of an inspector window. It shows the settings that
belong to selected component. It could be invoked from configurations pop-up menu in
the Components view (click on a configuration with the right-button and choose the
Configuration Inspector). For details on configurations, refer to the Configurations topic.
Properties
The Properties tab contains optimization settings related to the configuration. These
settings should be used when the code is already debugged. It could increase speed of the
code, but the generated code is less protected for the unexpected situations and finding
errors could be more difficult.
Note that some of the options may not be present for all Processor Expert versions.
Ignore range checking This option can disable generation of the code that
provides testing for parameter range. If the option is set to yes, methods do not
return error code ERR_VALUE neither ERR_RANGE. If the method is called with
incorrect parameter, it may not work correctly.
Ignore enable test This option can disable generation of the code that provides
testing if the component/peripheral is internally enabled or not. If the option is set to
yes, methods do not return error code ERR_DISABLED neither ERR_ENABLED. If
the method is called in unsupported mode, it may not work correctly.
Ignore speed mode test This option can disable generation of the code, that
provides a testing, if the component is internally supported in the selected speed
mode. If the option is set to yes, methods do not return error code ERR_SPEED. If
the method is called in the speed mode when the component is not supported, it may
not work correctly.
Use after reset values This option allows Processor Expert to use the values of
peripheral registers which are declared by a chip manufacturer as default after reset
values. If the option is set to no, all registers are initialized by a generated code, even
48
User Interface
Processor View
if the value after reset is the same as the required initialization value. If the option is
set to yes, the register values same as the after reset values are not initialized.
Complete initialization in Peripheral Init. Component This option can disable
shared initialization peripheral in Init methods of Peripheral Initialization
Components. If this option is set to yes, the complete peripheral initialization is
provided in Init method, even for parts that are already initialized in processor or
elsewhere. It could mean longer code, but the initialization can be repeated in
application using the Init method.
Processor View
This view displays selected target microcontroller with its peripherals and pins. It allows
you to generate code from processor and also to switch the CPU package. To open this
vew, click Window > Show View > Other... and select Processor Expert > Processor.
Figure 2.26 Processor View
You can change the CPU package when the Components view is not being displayed by
selecting the Select New CPU Package option on Processor view.
49
User Interface
Processor View
Figure 2.27 Processor View Select New CPU Package
Control Buttons
The following table lists and describes the control buttons:
Table 2.3 Control Buttons
Buttons
Description
Zoom in Increases the detail level of the
view. The whole picture might not fit the
viewing area.
Zoom out Decreases the detail level of the
view. Processor Expert tries to fit the whole
picture to the viewing area.
Rotate Rotates the package clockwise.
Resources (available for BGA type packages
only) Selects Resources view mode that
shows a top side of the package without pins
but including list of peripherals and showing
their allocation by components.
50
User Interface
Processor View
Table 2.3 Control Buttons
Buttons
Description
Pins Bottom (available for BGA type
packages only) Selects Pins view mode
that shows a bottom side of the package with
pins. The peripherals are not shown in this
mode beacause the surface is covered with
pins.
Pins Top Selects Pins view mode that
shows a top side of the package with pins.
Pins
The following information about each pin is displayed on the processor picture:
(in case of BGA type package the pins are displayed only in the Pins view mode)
pin name (default or user-defined)
icon of a component that uses (allocates) the pin
direction of the pin (input, output, or input/output) symbolized by blue arrows if a
component is connected
With new pin model (supported for few derivatives only), the background color of
the pin reflects routing of the pin to the peripheral.
Pin names are shortened and written either from left to right or from top to bottom and are
visible only if there is enough space in the diagram.
Some signals and peripherals cannot be used by the user because they are allocated by
special devices such as power signals, external, or data bus. The special devices are
indicated by a special blue icons. The allocation of peripherals by special devices can be
influenced by processor component settings.
In case of BGA package, the pins that are used by some component are colored yellow.
Move the cursor on the pin to get detailed information.
Hints
Pin hint contains:
number of the pin (on package)
both names (default and user-defined)
owner of the pin (component that allocates it)
short pin description from processor database
51
User Interface
Processor View
Component icon hint contains:
component name
component type
component description
Shared Pins
If a pin is shared by multiple components, the line connecting the pin to the component
has a red color. Refer to the Pin Sharing topic for details.
On-chip Peripherals
The following information about each on-chip peripheral is displayed on the processor
package:
peripheral device name (default or user-defined)
icon of the component that uses (allocates) the peripheral device
Peripheral device hint contains:
peripheral device name
owner of the pin (component that allocates it)
short peripheral device description
Hint on icon contains:
component name
component type
component description
If a peripheral is shared by several components (for example, several components may use
single pins of the same port), the icon is displayed.
NOTE
52
User Interface
Memory Map View
Zoom in Increases the detail level of the view. The whole picture might not fit the
viewing area.
Zoom out Decreases the size of the picture and detail level of the view.
Rotate Rotates the package by 90 degrees.
Pin Functional Properties This command is supported only if PinSettings
component is supported for the selected processor. It adds PinSettings component, if
it is not added in the project. It allows you to configure Pin Functional Properties
for the pin. The selected values are written directly to PinSettings component for the
pin.
Show Peripheral Initialization shows initialization values of all control, status
and data registers. This option is supported for all devices displayed on a processor
package. Refer to the Configuration Registers View for details.
Add Component/Template adds a component or template for the appropriate
peripheral; all available components and templates suitable for the selected
peripheral are listed. The components and templates in the list are divided by a
horizontal line. It is possible to add only components or templates which are
applicable for the peripheral. It means that is possible to add the component or
template only if the peripheral is not already allocated to another component or
components. The components/templates that cannot be added to the peripheral are
grayed in the pop-up menu as unavailable. This option is supported for all devices
displayed on processor package.
Remove Component allows to remove all components allocating peripheral in
Processor view. Processor component cannot be removed.
53
User Interface
Configuration Registers View
Table 2.4 Legend
Legend
Description
white: non-usable space
dark blue: I/O space
blue: RAM
light blue: ROM, OTP or Firmware
cyan: FLASH memory or EEPROM. This area can also contain a flash
configuration registers area.
black: external memory
The address in the diagram is increasing upwards. To improve the readability of the
information, the size of the individual memory blocks drawn in the window are different
from the ratio of their real size (small blocks are larger and large blocks are smaller).
The black line-crossed area shows the memory allocated by a component or compiler. The
address axis within one memory block goes from the left side to the right (it means that the
left side means start of the block, the right side means the end).
Figure 2.28 Sample Of Used Part Of The Memory Area
54
User Interface
Initialization Sequence View
Embedded Component settings When the peripheral is utilized by an Embedded
Component and the component settings are correct. Peripheral Initialization
Inspector shows initialization as required by the component settings.
Figure 2.29 Configuration Registers View
The table shows the registers and their initialization value displayed in the column Init.
value. You can modify the register value. Registers value can be changed if:
They are not read-only and when the project is without errors
Editing of configuration registers is supported by given component
This value written into the register or bit by the generated code during the initialization
process of the application. It is the last value that is written by the initialization function to
the register. The After reset column contains the value that is in the register by default
after the reset.
The values of the registers are displayed in the hexadecimal and binary form. In case the
value of the register (or bit) is not defined, an interrogation mark "?" is displayed instead
of the value. The Address column displays the address of registers.
NOTE
For some registers, the value read from the register after sometime can be
different than the last written value. For example, some interrupt flags are
cleared by writing 1. For details, refer to the microcontroller manual on
registers.
In case the peripheral is allocated by a component and the setting of the component is
incorrect, the initialization values are not displayed in the Configuration Registers view.
55
User Interface
Initialization Sequence View
Figure 2.30 Initialization Sequence
56
3
Application Design
This chapter will help you to design application using Processor Expert and Embedded
Components. You will find here recommendations and solutions to write and optimize a
code effectively.
This chapter explains:
Creating Application using Processor Expert
Basic Principles
Configuring Components
Implementation Details
Code Generation and Usage
Embedded Component Optimizations
Converting Project to Use Processor Expert
Low-level Access to Peripherals
Processor Expert Files and Directories
Static Code Support in Processor Expert
Internal signals
51
Application Design
Basic Principles
4. Code generation
After opening an example, invoke the code generation of the project to obtain all
sources. In the project tree, right-click the ProcessorExpert.pe file and select
the Generate Processor Expert Code command. The generated code is placed in the
Generated_Code sub-folder of the project.
The Processor Expert views can be opened any time using the menu command
Processor Expert > Show Views.
NOTE
Basic Principles
The application created in Processor Expert is built from the building blocks called
Embedded Components. The following topics describe the features of the Embedded
Components and the processor components that are special type of Embedded
Components and what they offer to the user.
Embedded Components
Processor Components
Embedded Components
Embedded components encapsulate the initialization and functionality of embedded
systems basic elements, such as microcontroller core, on-chip peripherals, (for details on
categories of components delivered with Processor Expert, refer to the Component
Categories topic) FPGAs, standalone peripherals, virtual devices, and pure software
algorithms.
These facilities are interfaced to the user through properties, methods and events. It is very
similar to objects in the Object Oriented Programming (OOP) concept.
Easy Initialization
You can initialize components by setting their initialization properties in the Component
Inspector. Processor Expert generates the initialization code for the peripherals according
to the properties of the appropriate components. You can decide whether the component
will be initialized automatically at startup or manually by calling the component's Init
method.
52
Application Design
Basic Principles
Methods
Methods are interfacing component functionality to user's code. All enabled methods are
generated into appropriate component modules during the code generation process. All
Methods of each component inserted into the project are visible as a subtree of the
components in the Components view.
You can use in your code all enabled methods. The easiest way to call any method from
your code is to drag and drop the method from Components view to the editor. The
complexity and number of methods depend on the component's level of abstraction.
Events
Some components allow handling the hardware or software events related to the
component. You can specify the name on function invoked in the case of event
occurrence. They are usually invoked from the internal interrupt service routines
generated by Processor Expert. If the enabled event handling routine is not already present
53
Application Design
Basic Principles
in the event module then the header and implementation files are updated and an empty
function (without any code) is inserted. You can write event handling code into this
procedure and this code will not be changed during the next code generation.
All Methods and Events of each component inserted into the project are visible as a
subtree of components in the Components view.
Interrupt Subroutines
Some components, especially the low-level components and the Peripheral Initialization
components (refer to more details in Component Categories topic) allow to assign an
interrupt service routine (ISR) name to a specific interrupt vector setup.
The name of the Interrupt service is generated directly to the interrupt vector table and you
have to do all necessary control registers handling within the user code. Refer to the
Typical Usage of Component in User Code topic for details.
ISRs items are listed in the subtree of a component in the Components view. Empty
Interrupt Service Routines (ISR) can be removed from the event module.
Figure 3.1 Example Of a Component With Two ISRs
Component Categories
Complete list of the component categories and corresponding components can be found in
the Component Categories page of the Components Library View.
The components are categorized based on their functionality, so you can find an
appropriate component for a desired function in the appropriate category.
These are the following main categories, which further contain various sub-categories.
Processor External Devices Components for devices externally controlled to the
processor. For example, sensors, memories, displays or EVM equipment.
Processor Internal Peripherals Components using any of on-chip peripherals
offered by the processor. The Components Library folder with the same name
contains sub-folders for the specific groups of functionality. For example,
Converters, Timers, PortIO.
54
Application Design
Basic Principles
NOTE
Logical Device Drivers LDD components. Refer to the Logical Device Drivers
topic for details.
Operating systems Components related to Processor Expert interaction with
operating system running on the target.
SW Components encapsulating a pure software algorithms or inheriting a
hardware-dependent components for accessing peripherals. These components
(along with components created by the user) can be found in a components library in
the folder SW.
Specific functionality of the microcontroller may be supported as a version-specific
settings of the component. For more information about this feature, refer to the Version
specific parts in the component documentation or Components Implementation Details
topic.
Levels of Abstraction
Processor Expert provides components with several levels of abstraction and
configuration comfort.
LDD Components Logical Device Drivers. The LDD components are efficient
set of components that are ready to be used together with RTOS. They provide a
unified hardware access across microcontrollers allowing to develop simpler and
more portable RTOS drivers or bare board application. Refer to the Logical Device
Drivers topic for details.
High Level Components Components that are the basic set of components
designed carefully to provide functionality to most microcontrollers in market. An
application built from these components can be easily ported to another
microcontroller supported by the Processor Expert. This basic set contains for
example components for simple I/O operations (BitIO, BitsIO, ByteIO, ...), timers
(EventCounter, TimerInt, FreeCntr, TimerOut, PWM, PPG, Capture, WatchDog,...),
communication (AsynchroSerial, SynchroMaster, SynchroSlave, AsynchroMaster,
AsynchroSlave, IIC), ADC, internal memories.
This group of components allows comfortable settings of a desired functionality such
as time in ms or frequency in Hz without user knowing about the details of the
hardware registers. microcontroller specific features are supported only as processor
specific settings or methods and are not portable.
55
Application Design
Basic Principles
The components inheriting or sharing a high-level component(s) to access hardware
are also high-level components.
Low Level Components Components that are dependent on the peripheral
structure to allow you to benefit from the non-standard features of a peripheral. The
level of portability is decreased due to a different component interface and the
component is usually implemented only for a microcontroller family offering the
appropriate peripheral. However, you can easily set device features and use effective
set of methods and events.
Peripheral Initialization Components Components that are on the lowest level
of abstraction. An interface of such components is based on the set of peripheral
control registers. These components cover all features of the peripherals and are
designed for initialization of these peripherals. Usually contain only Init method,
refer to the Typical Usage of Peripheral Initialization Components topic for details.
The rest of the function has to be implemented using a low level access to the
peripheral. This kind of components are located at: processor Internal Peripherals/
Peripheral Initialization Components of the components library and they are
available only for some processor families. The interface of these components might
be different for a different processor. The name of these components starts with the
prefix 'Init_'.
Table 3.1 Features of Components at Different Level of Abstraction
56
Feature
LDD
Components
High
level
Low level
Peripheral
Init
High-level settings
portable between
different
microcontroller families
partially
yes
partially
no
Portable method
interface for all
processor families
yes
yes
partially
(usually
direct access
to control
registers)
Init method
only
Processor specific
peripheral features
support
mostly yes
partially
mostly yes
full
Low-level peripheral
initialization settings
partially
no
partially
yes
Speed mode
independent timing
yes
yes
mostly yes
no
Application Design
Basic Principles
Table 3.1 Features of Components at Different Level of Abstraction
Feature
LDD
Components
High
level
Low level
Peripheral
Init
Events support
yes
yes
yes
no (direct
interrupt
handling)
Software emulation of
a component function
(if the specific
hardware is not
present)
no
yes
no
no
yes
no
no
no
57
Application Design
Basic Principles
LDD components have RTOS adapter support allowing to generate variable code for
different RTOSes.
Runtime enable/disable of component events.
Low Power Modes support.
RTOS Adapter
The RTOS adapter component is a way how to utilize generated code to the specific
RTOS. The RTOS adapter provides necessary information to the driver which API should
be used to allocate memory, create a critical section, allocate interrupt vector.
58
Application Design
Basic Principles
Figure 3.2 Example of HAL Integration into Existing RTOS
Shared Drivers
Logical device drivers support the shared mode that means that more components can be
put together to provide one instance of API. You can access each component instance
through the API of the shared component. A driver device data structure is used for
resolution which peripheral instance shall be accessed. Currently there are three
components that support shared mode: Serial_LDD, CAN_LDD and Ethernet_LDD.
59
Application Design
Basic Principles
Figure 3.3 Usage of Low Power API in Logical Device Drivers
In the example above, DPM (Dynamic Power Manager) task may opt to care for a selected
number of peripherals for graceful power mode change (for example, FEC, CAN) and rest
of the peripheral drivers need not know the power mode change. When opted for
informing a peripheral device driver, the DPM can build a semaphore object for low
power acknowledgement from the device drivers. When all such acknowledgements arrive
(ie. Semaphore count equals zero) the processor can be placed into a wait/sleep power
mode. In the future, with silicon design modifications, these semaphores can be
implemented in the hardware and as a result a much faster power mode change can be
expected. There is no DPM in typical bare-metal applications the DPM task is
implemented. In this case, DPM is substituted by a user application code.
Processor Components
A processor component is an Embedded Component encapsulating one processor type. A
Processor Expert project may contain one or more processor components. The project
generated for one processor is called an application. Processors included in a project are
displayed in the upper part of the Components view. It is possible to switch among the
processor component, but only one of the processor can be active at one time.
The Build options accessible in the Component Inspector of the processor component
allow you to set properties of the Compiler and Debugger (if it is supported).
60
Application Design
Basic Principles
Portability
It is possible to change the target microcontroller during the development of an
application and even to switch between multiple microcontrollers. This can be done
simply by adding another processor to the project and selecting it as the target
processor.
To connect the new processor peripherals to the application components correctly, it
is possible to specify the processor on-chip peripheral names. This way the same
peripheral could be used on different processor derivatives even if the original name
is different.
Changing Settings
To modify the processor component settings (its properties, methods, events, external bus,
timing, user-reserved peripherals, compiler and debugger settings) is to invoke the
Inspector for the selected processor component.
If you have added processor to your project, you can invoke Component Inspector by
performing either of the following:
Right-click the processor icon in the Components view to display pop-up menu and
select the Component Inspector view.
61
Application Design
Basic Principles
Double-click the processor icon in the Components view.
For a detailed description of the current processor properties, methods and events, select
Help on Component command in the View menu (drop-down arrow) in the Component
Inspector view.
In this dialog, you can select processor pin-variants and configurations that will be
supported for switching later in the project. Each selection of variant or configuration
represent one processor component pre-set. For example, if you select two pin variants
and two configuration, there will be four processor components added into the project.
If you have selected Initialize all peripherals checkbox, it adds all initialization
components to the project for all supported peripherals.
NOTE
62
This option is not supported for all derivatives. If supported on given family,
the project can contain except the CPU component and the PinSettings
component for configuring pin routing and electrical properties.
Application Design
Basic Principles
The project wizard offers support for CPUs that how the static files are used in the
Processor Expert project. There are two project modes:
In Linked mode, static files (for instance, cpu and peripheral init modules, PDD
modules, io map, system files) are linked from the repository of Processor Expert
(ProcessorExpert\lib\subdirectory). Modification of these files is
possible only in the Processor Expert's repository and affects other projects.
In Standalone mode, static files (for instance, cpu and peripheral init modules, PDD
modules, io map, system files) are placed in the project folder. They are copied from
Processor Expert's repository (ProcessorExpert\lib\subdirectory)
during project creation. This mode allows to modify the static files in the project
without affecting other projects.
NOTE
Compiler Selection
This dialog is shown when you add a new processor component into project using
Components Library view.
If there are more target compilers available, you can select the compiler to be used for the
newly added processor.
Figure 3.5 Compiler Selection
63
Application Design
Basic Principles
Speed Modes are not available for Kinetis and ColdFire+ family
microcontrollers.
The processor component supports up to three different speed modes. The three speed
modes are Processor Expert specific concept which (among all the other PE features and
concepts) ensures the portability of the PE projects between different processor models.
In fact, the three speed modes are a generalization of all the possible processor clock speed
modes used for power-saving that can be found in most of the modern microcontrollers. In
the area of embedded systems, power saving and power management functions are so
important that you can not neglect the proper HW- independent software implementation
of these functions.
Therefore, for keeping the portability (HW independence) of PE projects, it is
recommended not to program the processor speed functions manually, but use these three
processor Component speed modes instead:
High speed mode this mode is selected after reset and must be enabled in the
project. This speed mode must be the fastest mode of the main processor clock.
Low speed mode this mode is usually used for another PLL or main prescaler
settings of the main processor clock.
Slow speed mode this mode is usually used for the slowest possible mode of the
main processor clock.
64
Application Design
Basic Principles
65
Application Design
Basic Principles
Clock Configuration
Typical processor or microcontroller allows multiple reference clock sources usage,
contains clock synthesis modules to process these reference clocks and distribute them
across the system. This system timing scheme provides a set of clocks produced by the
system modules and is described as a clock path which starts at selected reference clock
source, such as internal oscillator or external crystal, and ends at variety of processor
internal clocks, such as core (instruction) clock or other clocks consumed by internal
peripherals.
Clock configuration is feature allowing design time creation and management of multiple
system timing schemes and is handled by a CPU (processor) component. This feature is
derived from the Speed modes used by the high-level components. For more details, see
Speed Modes Support topic.
The following schematic illustrates a simple system timing scheme. It consists of internal
and external reference clock, general clock generator module and several internal modules
that can consume variety of clocks. The orange block represents modules involved in
clock generation and distribution whereas, blue and green blocks denote clock consumers.
For example, core module and all internal peripherals can be clocked from divided clock
generator output or from divided internal or external reference clock. Additionally,
internal peripheral 3 can be fed directly from internal reference clock and internal
peripheral 2 also directly from external reference.
66
Application Design
Basic Principles
Figure 3.6 System timing scheme example
In Processor Expert, the orange blocks represents clock configuration and the green blocks
represents embedded components. As mentioned, clock configurations are configured in
the CPU (processor) component.
There user can make selection of used reference clock and specify configuration of clock
generator modules and dividers. Finally, in CPU component user always select frequency
of all major processor clocks, such as core, system or flash memory frequencies that is
clock, which define speed of the whole system, or peripheral bus clocks, which influence
timing characteristics of chip internal peripherals. embedded components relies on these
values and use them as the input value for timing features they encapsulate. The
relationship between clock configurations set in the CPU (processor) component and
embedded components is explained in Support of Clock Configurations in Embedded
Components topic.
There is always at least one clock configuration in the project - Clock configuration 0.
However, it is possible to use more clock configurations in the same project. For example,
use case of multiple clock configuration is in Multiple Clock Configuration topic.
67
Application Design
Basic Principles
to make a measurement, computation and communication with external devices. When the
job is done, microcontroller is switched back to sleep.
The figure below shows situation when application runs, the microcontroller is clocked
from an external source, the reference clock is processed by internal clock circuits
(forexample, clock frequency is increased by PLL module) and distributed across system.
Core and IP 1 run from divided output of internal clock generator (data computation and
communication interface handling) whether IP 2 runs directly from external reference
clock (for example, because frequency from clock generator output is out of admissible
range of this peripheral). Internal reference clock and IP 3 are not used therefore are
powered down.
Figure 3.7 Clock configuration example in application run state
The next schematic shows low-power configuration, an internal clock reference is used
instead of external as it spends less energy. No computation power is needed nor any
peripheral that would need high speed clocks enabled, therefore core is powered off along
with the clock generator circuits. Only IP 2 and IP 3 are enabled and clocked directly from
the internal clock source, waiting for event that will bring the microcontroller back to
operational mode.
68
Application Design
Basic Principles
Figure 3.8 Clock configuration example in application low-power state
This example also shows that some peripherals allow using multiple clock sources (for
instance clock generator output, raw output from reference clock source or other
alternative clocks). Clock configuration in such case can be used to switch clock source of
the peripheral clock input. Furthermore, the example demonstrates possibility to enable or
shut down entire peripheral during clock configuration switch. For more information
about clock configuration options available in the embedded components, see Support of
Clock Configurations in Embedded Components topic. Clock configuration switch is
explained in the topic below.
69
Application Design
Basic Principles
Note that during the transition period glitches at the peripheral outputs may occur.
Therefore, it is recommended to temporarily disable the peripherals before the clock
configuration is switched to prevent any unpredictable behavior.
Clock Configuration 0
Unlike other clock configurations, Clock Configuration 0 has some specific features:
Clock Configuration 0 is always in the project. Each project has to have at least one
clock configuration.
Application execution always starts in the Clock Configuration 0. Before main()
function execution starts, startup code of Processor Expert initializes the system
timing according to settings of this clock configuration.
All Peripheral Initialization Components timing settings relates to Clock
Configuration 0 (see Levels of Abstraction topic). Because multiple clock
configurations are not supported in initialization components, timing-related values
or information showed in the initialization components are valid for initial system
timing. For example, if a specific timer period value is calculated from current
divider property settings and showed as additional information in the component
then this time value is valid only for Clock Configuration 0 and might be different
when the clock configuration is switched.
70
Application Design
Basic Principles
The following table shows number of supported clock configurations for each category of
embedded component.
Table 3.2 Supported Clock Configurations
Component Category
Clock Configurations
Note
Peripheral Initialization
Clock configuration 0
High-level
Speed modes
LDD
There are two main clock configuration features available in embedded components:
Enabled clock configurations selection
Timing settings
This feature is not supported by components that don't control the whole peripheral.
Typical example are pin manipulation components, such as BitIO_LDD or
ExtInt_LDD which are related just to single pin from a port peripheral and multiple
instances of these components can be used on the same port. Components that support this
feature must have at least one enabled clock configuration.
71
Application Design
Basic Principles
Timing settings
Timing settings are vital part of functionality of some peripherals. For example, in case of
timer peripheral, it would be period of counter overflow, conversion time of analogtodigital converter or baud rate of communication interface. Configuration of these
features in the high-level and LDD components is done in the Timing Settings dialog.
This user-friendly interface allows configuration of peripheral timing settings. Generally,
user can specify required timing value directly or pick up the suitable value from list of
values computed according to current settings. For detailed documentation, see Dialog
Box for Timing Settings topic and Timing Settings topic.
Fixed timing value
Timing value is same for all clock configurations. The default behavior of embedded
components is to keep the value set in the timing settings same for all clock
configurations. Component will ensure that peripheral will be configured to achieve
required timing value regardless of the timing scheme used in particular clock
configuration. For example, timer component set to produce interrupt with specific period
will configure underlying peripheral in such a manner that for each clock configuration in
which the component is enabled it will produce the interrupt with the same period.
Similarly, communication component will transfer data with the same baud rate in all
enabled clock configurations.
Processor Expert contains timing model of each peripheral and check values entered by
the user. If required value is not achievable for some particular clock configuration, user is
already informed about that during the design time. This approach is common for all
embedded components. However, some of the components additionally allow creating list
of timing values and switching between them using dedicated, component-specific
method. For more information about available types of timing values, see Runtime Setting
Configuration topic.
Input clock source selection
Often peripherals can be clocked not only from internal peripheral bus, but also from
variety of alternative clock sources, such as dedicated asynchronous clock generator or
any other system clock source. Although, the way how such selection is implemented is
component-specific and might be common for all clock configurations, it is common
practice that high-level and LDD components allow selecting input clock source for each
clock configuration independently, switching between them during the application
runtime (during SetClockConfiguration() method call). If peripheral input clock
is not available, for example, because the clock configuration is set to disable the required
reference clock source, the Processor Expert notifies the user about this.
72
Application Design
Configuring Components
Configuring Components
Configuring the components in the project is one of the main activities in Processor
Expert. It affects the initialization, run-time behavior and range of functionality available
to the generated code. For the description of the user interface of the components settings,
refer to the Components View and Component Inspector.
The following topics provide hints and information about how to configure the Embedded
Components used in the project correctly and effectively.
Interrupts and Events
Configurations
Design Time Checking: Consequences and Benefits
Timing Settings
Creating User Component Templates
Signal Names
Component Inheritance and Component Sharing
Pin Sharing
Export and Import
73
Application Design
Configuring Components
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 for that case are invoked from the generated ISR. Moreover, the event can also be a
software event caused by a buffer overflow or improper method parameter.
It is a common bug in user code, if the application is 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. Refer to the description of the property Interrupt service/event for
detailed information about the particular component.
Enabling Event
Functionality of each event can be enabled or disabled. You 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 Component Inspector view.
Figure 3.10 Event Example in the Component Inspector Events Tab
74
Application Design
Configuring Components
Interrupt Priority
You may select interrupt priority in the component properties, just below the interrupt
vector name. Processor Expert offers the following values, which are supported for all
microcontrollers:
minimum priority
low priority
medium priority
high priority
maximum priority
75
Application Design
Configuring Components
The selected value is automatically mapped to the priority supported by the target
microcontroller. It is indicated in the third column of the Component Inspector view.
You may also select a target-specific numeric value (such as priority 255), if portability of
the application to another architecture is not required.
Peripheral Initialization components on some platforms also allow to set the default value
that means that you don't have any requirement, so the priority value will be the default
after-reset value.
76
Some events do not support priorities because their invocation is not caused by
the interrupt processing.
Application Design
Configuring Components
WARNING!
Processor Expert does not allow you to decrease an event code priority
(with the exception of 'Interrupts enabled' value on some platforms).
This is because Processor Expert event routines are not generally
reentrant so there is a risk that the interrupt would be able to interrupt
itself during the processing. If there is such functionality requested, you
have to do it manually (for example, by calling a appropriate processor
component method setting a priority) and carefully check possible
problems.
Configurations
You can have several configurations of the project in one project file. The configuration
system is very simple. Every configuration keeps the enable/disable state of all
components in the project (it does not keep any component settings). If you enable/disable
a component in the project, the component state is updated in the currently selected
configuration. If you create a new configuration the current project state is memorized.
Configurations of the current project are listed in the Generator_Configurations folder
of the Components view.
Configurations can also hold additional settings that may influence code generation. These
settings can be changed in the configuration inspector. Refer to the Configuration
Inspector for details.
The symbol for conditional compilation is defined if it is supported by the selected
language/compiler. The symbol PEcfg_[ConfigurationName] is defined in the processor
interface.
You can switch using this symbol between variants of code according to the active
configuration (see example in this chapter).
Configuration also stores which processor is selected as the target processor.
If the name of the configuration matches the name of one of the CodeWarrior's targets, the
target is automatically selected as an active target when the user runs code generation.
NOTE
It is possible to have two components with the same name in project. Each of
the components could be enabled in different configuration. This way you can
have different setup of a component (a component with the same name) in
multiple configurations.
77
Application Design
Configuring Components
Example
Suppose, there is a configuration named, Testing case. You can use a component and
part of our code using the component only in the Testing case configuration. Then
you can make the testing case configuration active. After the successful code generation,
the Cpu.h file contains the following definition:
/* Active configuration define symbol */
#define PEcfg_Testingcase 1
Add the following lines:
...
#ifdef PEcfg_TestingCase
Component_MethodCall(...);
#endif
...
On-Chip Peripherals
Some components use on-chip peripherals. In the Component Inspector, you can choose
from all possible peripherals that can be used for implementation of the function of the
current component. Processor Expert provides checking for required peripheral features
such as word width and stop bit for serial channel, pull resistor for I/O pin and others.
Processor Expert also protects against the use of one peripheral in two components. If the
peripheral is allocated for one component then the settings of this peripheral cannot be
changed by any other component. The state of an allocated peripheral should never be
changed directly in the user code. (Using special registers, I/O ports etc.) It is
recommended to always use methods generated by Processor Expert. If the functionality
of generated methods is not sufficient for your application, you can use PESL (Processor
Expert System Library). Refer to the Low-level Access to Peripherals topic for details.
Note that if a peripheral is allocated to any component, all its parts are reserved. For
example, if you use the 8-bit I/O port, all the I/O pins of the port are allocated and it is not
possible to use them in other components.
78
Application Design
Configuring Components
In some timer components, you can choose if you want to use only a part of the timer
(compare register) or an entire timer. If you select the entire timer, the driver can be
optimized to work best with the timer. For example, invoke reset of the timer whenever it
is needed by the component function.
Interrupt Priority
If the target processor shares interrupt priority between several interrupt vectors or shares
interrupt vectors, Processor Expert provides checking of interrupt priority settings. For
detailed information about Interrupt Priority, refer to the Interrupt Priority topic.
Memory
Processor Expert always checks the usage of the internal and external memories accessible
throught processor address and data bus. Position and size of internal memory is defined
by the processor type and can be configured in the processor Properties (if supported).
External memories must be defined in processor Properties.
Any component can allocate a specific type of memory. Processor Expert provides
checking of memory and protects you from making a wrong choice. For example, if a
component requires external Flash, it is not possible to enter an address in internal RAM.
The bits can also allocate memory. Therefore, you can be sure that only one component
uses an allocated bit of a register in external address space.
Timing
The settings of all timed high-level components are checked using the internal timing
model. Refer to the Timing Settings topic for details. If there is no error reported, it means
that Processor Expert was successful in calculating the initialization and runtime control
values for all components and hence the settings should work according to the
configuration.
Timing Settings
Many high-level components contain a timing configuration (for example, speed of the
serial communication, period of the interrupt, conversion time of the ADC). Processor
Expert allows to configure such timing using user-friendly units and it also contains a
model of the complete microcontroller timing. This model allows calculation of the
required values of control registers and continuous validation of the timing settings.
79
Application Design
Configuring Components
Timing Model
A component timing can be viewed like a chain of elements, such as dividers and
multipliers between the main clock source and the device configured by the component.
You can set the desired timing value using the Timing dialog box (refer to the Dialog Box
for Timing Settings topic for details) or directly by specifying the value in Component
Inspector (refer to the Syntax for the Timing Setup in the Component Inspector topic for
details). Processor Expert tries to configure individual elements in the timing chain to
achieve the result and the user is informed if it was successful. After leaving the Timing
dialog box, the real value of the timing is shown in the third column of the component
inspector.
80
Application Design
Configuring Components
Speed Modes
Processor Expert provides three speed modes that are generalization of all the possible
processor clock speed modes used for power-saving supported by most of the modern
microcontrollers. Refer to the Speed Modes Support topic for details.
81
Application Design
Configuring Components
Figure 3.11 Component Template
3. The template appears within the Components Library View and can be inserted into
projects. It may be necessary to invoke refresh command by selecting the pop-up menu
of Components Library and select Refresh option.
Figure 3.12 Components Library View
Signal Names
The main purpose of signals allows you to name the pins used by components with names
corresponding to the application.
82
Application Design
Configuring Components
Assign a different signal names to individual pins by writing pin signal names (from
the lowest bit to the highest one) separated by commas or spaces into the Port signal
property.
Figure 3.13 Signal Names List for a Port
Generated Documenation
Processor Expert automatically generates a document
{projectname}_SIGNALS.txt or {projectname}_SIGNALS.doc containing
a list of relationship between defined signals and corresponding pins. There is an
additional signal direction information added next to each signal name and pin number
information next to each pin name. This document can be found in the Documentation
folder of the Component view.
Listing 3.1 Sample of Generated Signals Documentation
=================================================================
SIGNAL LIST
----------------------------------------------------------------SIGNAL-NAME [DIR] => PIN-NAME [PIN-NUMBER]
----------------------------------------------------------------LED1 [Output] => GPIOA8_A0 [138]
LED2 [Output] => GPIOA9_A1 [10]
Sensor [Input] => GPIOC5_TA1_PHASEB0 [140]
TestPin [I/O] => GPIOE0_TxD0 [4]
Timer [Output] => GPIOC4_TA0_PHASEA0 [139]
=================================================================
=================================================================
PIN LIST
----------------------------------------------------------------PIN-NAME [PIN-NUM] => SIGNAL-NAME [DIRECTION]
----------------------------------------------------------------GPIOA8_A0 [138] => LED1 [Output]
GPIOA9_A1 [10] => LED2 [Output]
GPIOC4_TA0_PHASEA0 [139] => Timer [Output]
GPIOC5_TA1_PHASEB0 [140] => Sensor [Input]
GPIOE0_TxD0 [4] => TestPin [I/O]
=================================================================
83
Application Design
Configuring Components
Inheritance
Inheritance in Processor Expert means that an ancestor component is used only by the
descendant component. Inheritance is supported in order to allow components to access
peripherals by hardware-independent interface of the ancestor components. For example,
a component that emulates a simple I2C transmitter may inherit two BitIO components for
generation of an output signal.
On several complex components inheritance is used to separate component settings into
several logical parts, for example, settings of channel is inherited in the component with
settings of the main peripheral module.
Processor Expert allows you to select from ancestors that implement the required interface
and are registered by the descendant component.
The ancestor component is displayed under its descendant in the project structure tree in
the Components view.
Figure 3.15 Example of Ancestor and Descendant Components in the Components View
84
Application Design
Configuring Components
An ancestor component requires a list of methods and events ( interface ), which must be
implemented by an ancestor component. The error is shown if the ancestor component
does not implement any of them. For example, if the settings of the descendant component
do not allow it to generate this method.
Component Sharing
Component sharing allows you to cause several components to use capability of one
component similar to inheritance. This feature allows sharing of its resources and its
drivers with other components. For example, components may share an I2C component
for communication with peripherals connected to the I2C bus or some component may do
DMA transfers using DMA component.
Pin Sharing
Sharing Pins Among Peripherals
Some processors allows few pins to be used by multiple peripherals. This may lead to the
need of sharing pin(s) by multiple components. Normally, if you select one pin in more
85
Application Design
Configuring Components
than one component, a conflict is reported. However, it is possible to setup a sharing for
such pin in the component inspector.
One of the components sharing a pin has to be chosen as a main component. This
component will initialize the pin. In the properties of other components that use the pin,
the pin has to be marked as shared (see figure below).
Pin sharing can be set in the Component Inspector. The Component Inspector must be
in Expert view mode. Use the pop-up menu of the property and select the command Pin
Sharing Enabled.
Figure 3.17 Pin Property with Sharing Enabled
Pin sharing is advanced usage of the processor peripherals and should be done only by
skilled users. Pin sharing allows advanced usage of the pins even on small processor
packages and allows application-specific usage of the pins.
ConnectPin Method
It is necessary to invoke the component method ConnectPin to connect a component to
the shared pin. It is also necessary to invoke the main component method to connect pin
back to the main component. In fact, the peripherals can usually operate simultaneously,
but they have no connection to the shared pins unless the ConnectPin method is
executed. In case that all components control the shared pin using one peripheral, it is not
necessary to use the ConnectPin method.
Shared pins are presented in the Processor View as well. The component to pin connection
line is red.
86
Application Design
Configuring Components
Configurations
Operating system
Processors
Components
To export component settings:
1. In the IDE, select File > Export. The Export wizard appears.
Expand Processor Expert tree. Select Export Component Settings option as shown
below.
Figure 3.18 Export Wizard
2. Click Next. The Export Processor Expert Component Settings page appears.
87
Application Design
Configuring Components
Figure 3.19 Export Processor Expert Component Settings Page
In the left panel, select the project for which you want to export the component
settings. In the right panel, select the components to export. Click the Browse button
to select the output file in which the export settings are saved. The default location for
saving the output file is recently selected folder, your home directory. The extension of
the file is .pef.
3. Click Finish to complete the exporting of component settings.
88
Application Design
Configuring Components
Figure 3.20 Export Wizard
2. Click Next. The Expert Processor Expert Board Configuration page appears.
Figure 3.21 Expert Processor Expert Board Configuration Page
In the left panel, select the project for which you want to export the board settings. In
the right panel, the processor and components are already selected. Click the Browse
button to select the output file in which the export settings are saved. The default
location for saving the output file is either recently selected folder or your home
directory. The extension of the file is .peb.
89
Application Design
Configuring Components
3. Click Finish to complete the exporting of board configurations.
90
Application Design
Configuring Components
Figure 3.23 Apply Board Configuration Page
Before importing, you can rename some of the components (as shown in figure above),
so it will show the mapping of components with different names, but same device
allocation.
To import component settings from the file to selected project, click the Browse
button. Select the input file with the .peb extension. The default option Replace
settings is selected if imported component settings are having same peripheral device
allocation (or ID) and type.
For more information on different types of modes, refer to the Component Settings to
Project topic.
3. Click Finish. The settings from the .peb file is imported to the selected project.
91
Application Design
Configuring Components
Figure 3.24 Import Wizard
92
Application Design
Configuring Components
Figure 3.25 Import Component Settings Page
To import component settings from the file to selected project, click the Browse
button. Select the input file with the .pef or .peb or .pe extension. The default
option Replace settings is selected if imported component settings are having same
name (or ID) and type.
You can select the mode for importing components settings, the options are:
Ignore do not import this component settings
Add new add new component with imported settings
Add new, keep existing if component with same name or type exists, it will
add a new component with imported settings and keep the existing one (may
cause conflicts)
Add new, disable existing if component with same name or type exists, it
will add a new component with imported settings and disable the existing one
Replace settings replace existing component with new settings from
imported file
3. Click Finish. The settings from the .pef file is imported to the selected project.
93
Application Design
Configuring Components
Figure 3.26 Import Wizard
3. Click Finish to select and install Processor Expert update packages (.PEUpd) files.
94
Application Design
Implementation Details
Implementation Details
This topic explains implementation details for Embedded Components and Processor
Expert generated code.
The following describes:
Reset Scenario with PE for ColdFire and Kinetis Microcontrollers
Version Specific Information for Kinetis and ColdFire+
Additional implementation specific information can be found on individual component
documentation pages.
95
Application Design
Implementation Details
96
Application Design
Implementation Details
_startup()
The _startup() function is called as the first function after the reset. The
_startup() function initializes the stack pointer, calls the
__initialize_hardware() function and continues with initialization of the
enviroment (such as memory initialization). At the end of the _startup() function the
main() function is called.
__initialize_hardware()
The __initialize_hardware() function is called from the _startup function
after an initialization of the stack pointer. This function is defined in the cpu module,
usually Cpu.c, and provides necessary system initialization such as PLL, and external
bus.
Sometimes it is necessary to do some special user initialization immediately after the cpu
reset. Processor Expert provides a possibility to insert user code into the
__initialize_hardware() function. There is a User Initialization property in the
build options tab of a processor component inspector defined for this purpose. Refer to the
Component Inspector topic for details.
PE_low_level_init()
There is a second level of Processor Expert initialization PE_low_level_init()
called at the beginning of the main() function. PE_low_level_init() function
provides initialization of all components in project and it is necessary for proper
functionality of the Processor Expert project.
OnReset Event
You can write the code that will be invoked from the PE_low_level_init()
function after Processor Expert internal initialization, but before the initialization of
individual components. Thus, you should expect that peripherals are not completely
initialized yet. This event can be enabled/disabled in the processor component inspector's
events page.
97
Application Design
Code Generation and Usage
Kinetis and ColdFire+ processor components support Clock configurations that are similar
to Speed Modes (available with High Level components) but provide more options on
configuring low power and slow clock modes of the processor. Refer to the details on
individual settings in the processor component's on-line help.
Code Generation
ProcessorExpert.pe pop-up menu > Generate Processor Expert Code Generate Code
command initiates the code generation process. During this process source code modules
containing functionality of the components contained in the project are generated. The
project must be set-up correctly for successful code generation. If the generation is errorfree all generated source code files are saved to the destination directory.
98
Application Design
Code Generation and Usage
The processor module is generated according to the currently active target processor
component. The processor module additionally contains:
microcontroller initialization code
interrupt processing
Main module
The main module is generated only if it does not already exist (if it exists it is not
changed). Name of this module is the same as the name of the project.
The main module contains the main function, which is called after initialization of
the microcontroller (from the processor module). By default, this function is
generated empty (without any reasonable code). It is designed so that you can write
code here.
Event module
The event module is generated only if it does not exist. If it exists, only new events
are added into the module; user written code is not changed.
The event module contains all events selected in the components. By default, these
event handler routines are generated empty (without any meaningful code). It is
considered that user will write code here.
Event module can also contain the generated ISRs for the components that require a
direct interrupt handling (Peripheral Initialization Components). It is possible to
configure the name of event module individually for each component in the
ADVANCED view mode of the Component Inspector. However, note that the event
module is not generated by Processor Expert if there is no event enabled in the
component, except the processor component, for which the event module is always
generated.
Method list file with description of all components, methods and events generated
from your project. The name of the file is {projectname}.txt or
{projectname}.doc. This documentation can be found in the Documentation
folder.
Signal names
This is a simple text file {projectname}_SIGNALS.txt or
{projectname}_SIGNALS.doc with a list of all used signal names. The signal
name can be assigned to an allocated pin in the component properties (available in
ADVANCED view mode). This documentation can be found in the Documentation
folder of the Components view. Refer to the Signal Names topic for details.
Code generation log that contains information on changes since last code
generation. Refer to the Tracking Changes in Generated Code for details.
XML documentation containing the project information and settings of all
components in XML format. The generated file
99
Application Design
Code Generation and Usage
{projectname}_Settings.xml can be found in the Documentation folder of
the Components view. It is updated after each successful code generation.
Shared modules with shared code (the code which is called from several
components). Complete list of generated shared modules depends on selected
processor, language, compiler and on the current configuration of your project.
Typical shared modules are:
IO_Map.h
Control registers and bit structures names and types definitions in C language.
IO_Map.c
Control registers variable declarations in C language. This file is generated only
for the HC(S)08/HC(S)12 versions.
Vectors.c
A source code of the interrupt vector table content.
PE_Const.h
Definition of the constants, such as speed modes, reset reasons. This file is
included in every driver of the component.
PE_Types.h
Definition of the C types, such as bool, byte, word. This file is included in every
driver of the component.
PE_Error.h
Common error codes. This file contains definition of return error codes of
component's methods. See the generated module for detailed description of the
error codes. This file is included in every driver of the component.
PE_Timer
This file contains shared procedures for runtime support of calculations of timing
constants.
{startupfile}.c
This external module, visible in the External Modules folder of the Components
view, contains a platform specific startup code and is linked to the application.
The name of the file is different for the Processor Expert versions.
PESL".h
PESL include file. This file can be included by the user in his/her application to
use the PESL library. For more details, refer to the Processor Expert System
Library topic.
Application Design
Code Generation and Usage
only for projects with static code support. For more details, refer to the Project Static
Modules topic.
Configuration header files containing parameterization constants which controls
static source code. Configuration header file is generated for each component with
static code support added to the project. These modules are generated only for
projects with static code support. For more details, refer to the Peripheral
Initialization Component Files topic.
For more details, refer to the Predefined Types, Macros and Constants topic.
101
Application Design
Code Generation and Usage
- Documentation\ProcessorExpert.txt - regenerated
- Documentation\ProcessorExpert_Settings.xml - regenerated
# Other files have been modified due to internal interdependency:
- Generated_Code\PE_Timer.h - added
- Generated_Code\PE_Timer.c - added
# User modules
- Sources\ProcessorExpert.c - changed
> updated list of included header files
- Sources\Events.h - changed
> updated list of included header files
Totally 11 file(s) changed during code generation.
To view changes within the individual files, you can use a file pop-up menu command
Compare with > Local history... available in Components view. It allows to compare
files with the version before the code generation.
Types
The following table lists the predefined types and their description:
Table 3.3 Predefined Types
102
Type
Description
Supported for
byte
all
bool
all
word
all
dword
all
dlong
all
TPE_ErrCode
Application Design
Code Generation and Usage
Macros
__DI()
__EI()
EnterCritical()
ExitCritical()
103
Application Design
Code Generation and Usage
For the list of macros available for Peripheral registers access, refer to the Direct Access to
Peripheral Registers topic.
Constants
Methods Error Codes
The error codes are defined in the PE_Error module. Error code value is 8-bit unsigned
byte. Range 0 - 127 is reserved for PE, and 128 - 255 for user.
104
ERR_OK
OK
ERR_SPEED
ERR_RANGE
ERR_VALUE
ERR_OVERFLOW
Timer overflow
ERR_MATH
ERR_ENABLED
Device is enabled
ERR_DISABLED
Device is disabled
ERR_BUSY
Device is busy
ERR_NOTAVAIL
ERR_RXEMPTY
10
No data in receiver
ERR_TXFULL
11
Transmitter is full
ERR_BUSOFF
12
ERR_OVERRUN
13
Overrun is present
ERR_FRAMING
14
ERR_PARITY
15
ERR_NOISE
16
ERR_IDLE
17
ERR_FAULT
18
Application Design
Code Generation and Usage
ERR_BREAK
19
ERR_CRC
20
ERR_ARBITR
21
ERR_PROTECT
22
ERR_UNDERFLOW
23
ERR_UNDERRUN
24
ERR_COMMON
25
ERR_LINSYNC
26
ERR_FAILED
27
ERR_QFULL
28
Queue is full
105
Application Design
Code Generation and Usage
typedef unsigned int UInt16;
typedef long Int32;
typedef unsigned long UInt32;
typedef union
{
struct
{
UWord16 LSBpart;
Word16 MSBpart;
} RegParts;
Word32 Reg32bit;
} decoder_uReg32bit;
typedef struct
{
union { Word16 PositionDifferenceHoldReg;
Word16 posdh; };
union { Word16 RevolutionHoldReg;
Word16 revh; };
union { decoder_uReg32bit PositionHoldReg;
Word32 posh; };
}decoder_sState;
typedef struct
{
UWord16 EncPulses;
UWord16 RevolutionScale;
Int16 scaleDiffPosCoef;
UInt16 scalePosCoef;
Int16 normDiffPosCoef;
Int16 normPosCoef;
}decoder_sEncScale;
typedef struct
{
UWord16 Index :1;
UWord16 PhaseB :1;
UWord16 PhaseA :1;
UWord16 Reserved :13;
}decoder_sEncSignals;
typedef union{
decoder_sEncSignals EncSignals;
UWord16 Value;
} decoder_uEncSignals;
/
**********************************************************************
********
*
* This Motor Control section contains generally useful and generic
* types that are used throughout the domain of motor control.
*
106
Application Design
Code Generation and Usage
**********************************************************************
********/
/* Fractional data types for portability */
typedef short Frac16;
typedef long Frac32;
typedef enum
{
mcPhaseA,
mcPhaseB,
mcPhaseC
} mc_ePhaseType;
typedef struct
{
Frac16 PhaseA;
Frac16 PhaseB;
Frac16 PhaseC;
} mc_s3PhaseSystem;
/* general types, primary used in FOC */
typedef struct
{
Frac16 alpha;
Frac16 beta;
} mc_sPhase;
typedef struct
{
Frac16 sine;
Frac16 cosine;
} mc_sAngle;
typedef struct
{
Frac16 d_axis;
Frac16 q_axis;
} mc_sDQsystem;
typedef struct
{
Frac16 psi_Rd;
Frac16 omega_field;
Frac16 i_Sd;
Frac16 i_Sq;
} mc_sDQEstabl;
typedef UWord16 mc_tPWMSignalMask;
/* pwm_tSignalMask contains six control bits
representing six PWM signals, shown below.
The bits can be combined in a numerical value
that represents the union of the appropriate
bits. For example, the value 0x15 indicates
that PWM signals 0, 2, and 4 are set.
*/
107
Application Design
Code Generation and Usage
/* general types, primary used in PI, PID and other controllers */
typedef struct
{
Word16 ProportionalGain;
Word16 ProportionalGainScale;
Word16 IntegralGain;
Word16 IntegralGainScale;
Word16 DerivativeGain;
Word16 DerivativeGainScale;
Word16 PositivePIDLimit;
Word16 NegativePIDLimit;
Word16 IntegralPortionK_1;
Word16 InputErrorK_1;
}mc_sPIDparams;
typedef struct
{
Word16 ProportionalGain;
Word16 ProportionalGainScale;
Word16 IntegralGain;
Word16 IntegralGainScale;
Word16 PositivePILimit;
Word16 NegativePILimit;
Word16 IntegralPortionK_1;
}mc_sPIparams;
#endif /* __PE_Types_H */
#define MC_PWM_SIGNAL_0 0x0001
#define MC_PWM_SIGNAL_1 0x0002
#define MC_PWM_SIGNAL_2 0x0004
#define MC_PWM_SIGNAL_3 0x0008
#define MC_PWM_SIGNAL_4 0x0010
#define MC_PWM_SIGNAL_5 0x0020
#define MC_PWM_NO_SIGNALS 0x0000 /* No (none) PWM signals */
#define MC_PWM_ALL_SIGNALS (MC_PWM_SIGNAL_0 | \
MC_PWM_SIGNAL_1 | \
MC_PWM_SIGNAL_2 | \
MC_PWM_SIGNAL_3 | \
MC_PWM_SIGNAL_4 | \
MC_PWM_SIGNAL_5)
108
Application Design
Code Generation and Usage
109
Application Design
Code Generation and Usage
...
}
Application Design
Code Generation and Usage
}
NOTE
111
Application Design
Code Generation and Usage
When this option is set, Processor Expert places the call of the Init method into the
PE_low_level_init function of the CPU.c module.
Interrupt Handling
Some Peripheral Initialization components allow the initialization of an interrupt service
routine. Interrupt(s) can be enabled in the initialization code using appropriate properties
that can be usually found within the group Interrupts.
After enabling, the specification of an Interrupt Service Routine (ISR) name using the ISR
name property is required. This name is generated to Interrupt Vector table during the
code generation process. Please note that if the ISR name is filled, it is generated into the
Interrupt Vector Table even if the interrupt property is disabled.
Figure 3.29 Example of the Interrupt Configuration
Enabling/disabling peripheral interrupts during runtime has to be done by user's code, for
example by utilizing PESL or direct register access macros, because the Peripheral
Initialization Components do not offer any methods for interrupt handling.
The ISR with the specified name has to be declared according to the compiler conventions
and fully implemented by the user.
112
Application Design
Code Generation and Usage
NOTE
For 56800/E version users: ISRs generated by Processor Expert contain the fast
interrupt handling instructions if the interrupt priority is specified as fast
interrupt.
Deinit Method
Deinit() method disables a peripheral and frees the allocated memory if supported by
the RTOS adapter. Deinit() method is usually used in RTOS applications, not in baremetal applications.
113
Application Design
Code Generation and Usage
Interrupt Handling
Most of LDD components are designed to be used in the interrupt mode. It means that the
interrupt service routine (ISR) is called by the interrupt controller when an asynchronous
interrupt occurs. Interrupt service routine is defined in LDD driver and a user is notified
through components events. Events can be enabled or disable in the component inspector
according to an application needs. When an event is enabled, the appropriate function is
generated into Event.c, where a user can write own event handler code. Events are called
from the ISR context, so a user should keep an event code as short as possible to minimize
a system latency.
114
Application Design
Embedded Component Optimizations
General Optimizations
This chapter describes how to setup Processor Expert and components to generate
optimized code. The following optimization are only for the High or Low-level
components, and not for the Peripheral Initialization components.
When Processor Expert generates the code certain methods and events are enabled by
default setting, even when the methods or events are not needed in the application, and
thus while they are unused, the code may still take memory. Basically, the unused
methods code is dead stripped by the linker but when the dependency among methods is
complex some code should not be dead stripped. When useless methods or events are
enabled the generated code can contain spare source code because of these unused
methods or events. Moreover some methods can be replaced by more efficient methods
that are for special purposes and therefore these methods are not enabled by default.
115
Application Design
Embedded Component Optimizations
several configurations, its possible to add one component for each configuration with
same name and different setting.
Speed Modes
NOTE
Timed components which depend on the processor clock (such as timer, communication
and conversion components), may support speed modes defined in the processor
component (in EXPERT view level). The Processor Expert allows the user to set closest
values for the component timing in all speed modes (if possible) . If the requested timing
is not supported by the component, for example if the processor clock is too low for the
correct function of the component, the component can be disabled for the appropriate
speed mode. The mode can be switched in the runtime by a processor method. The
component timing is then automatically configured for the appropriate speed mode or the
component is disabled (according to the setting). Note, however, that use of speed modes
adds extra code to the application. This code must be included to support different clock
rates. See speed mode details here.
See chapter Embedded Component Optimizations for details on choosing and setting the
components to achieve optimized code.
116
Application Design
Embedded Component Optimizations
For better code size performance, it's recommended to not to use a bigger counter/reload/
compare register for timer than is necessary. Otherwise the code size generated by a
component may be increased (e.g. For 8-bit timer choose 8bit timer register).
In some cases, several timing periods are required when using timers (For example, the
TimerInt component). The Processor Expert allows changing the timer period during runtime using several ways (note that this is an advanced option and the Component Inspector
Items visibility must be set to at least 'ADVANCED').
These ways of changing the run-time period of timer requires various amount of code and
thus the total application code size is influenced by the method chosen. When the period
must be changed during run-time, use fixed values for period instead of an interval if
possible to save code. There are two possibilities (See Dialog Box for Timing Settings for
details. ):
From list of values - this allow to specify several (but fixed in run-time) number for
given periods. This allows only exact values - modes, listed in the listbox. The
resulted code for changing the period is less complex than using an interval.
From time interval - this is an alternative to using 'list of values', which requires
more code. Using an interval allows setting whatever value specified by the
component during run-time. This code re-calculates the time period to the processor
ticks and this value is used when changing the timer period.
If the application requires only a few different timing periods, even if the functionality is
the same for both cases, the correct usage of list of periods produces smaller code
compared to code using an interval.
117
Application Design
Embedded Component Optimizations
Communication components should be used with the smallest possible buffer. Thus the
user should compute or check the maximum size of the buffer during execution of the
application. For this purpose the method GetCharsInTxBuffer/GetCharsInTxBuffer
(AsynchroSerial component), which gets current size of a used buffer, can be used after
each time the SendBlock/RecvBlock method is called.
Use interrupts if you require faster application response. The interrupt routine is
performed only at the event time, that is the code does not check if a character is sent or
received. Thus the saved processor time can be used by another process and application is
faster.
Use polling mode instead of interrupts if you require less code because usually overhead
of interrupts is bigger than overhead of methods in polling mode. But the polling mode is
not suitable for all cases. For example when you use the SCI communication for sending
only the data, and a character is sent once in a while, then it is better to use the polling
mode instead of using interrupt because it saves the code size, that is when the interrupt is
used an interrupt subroutine is needed and code size is increased.
Examples
A module of an application sends once in a while one character to another device through
the SCI channel. If the delay between two characters is sufficient to sent one character at a
time then the polling mode of the SCI (the AsynchroSerial component) should be used in
this case.
A module of an application communicates with another device, that is it sends several
characters at one time and receives characters from the device. Thus the interrupt mode of
the SCI (the AsynchroSerial component) should be used in this case because when a
character is received the interrupt is invoked and the underlying process of the application
need not check if a character is received. When a buffer for sending is used, the characters
are saved into the buffer and AsynchroSerial's service routine of the interrupt sends these
characters without additional code of the application.
NOTE
118
Application Design
Converting Project to Use Processor Expert
119
Application Design
Low-level Access to Peripherals
Peripheral Initialization
It is possible to use Processor Expert to generate only the initialization code (function) for
a peripheral using the Peripheral initialization components. You can choose a suitable
Peripheral initialization component for the given peripheral using the Peripherals tab of
the Components Library. Refer to the Components Library View topic for details. Initial
values that will be set to the peripheral control registers can be viewed in the Peripheral
Initialization window. Refer to the Configuration Registers View topic for details.
PDD layer is available only for Kinetis, MC56F82xxx, and ColdFire+ family
microcontrollers.
Physical Device Drivers (PDD) is a software layer that provides set of methods for
accessing microcontroller peripheral configuration registers.
PDD methods abstract from: What kind of registers are available
How registers are organized
How they are named
120
Application Design
Low-level Access to Peripherals
PDD header files are located in {InstallDir}\Processor Expert\lib\{MCU}\pdd. Each file
contains a definitions of PDD methods for one microcontroller peripheral. Basic PDD
methods are implemented by macros and do not provide any additional functionality like
register masking, shifting, etc.
Peripheral Base Address
PDD method parameters start with the base address of the peripheral. If user is writing a
code which is using a peripheral initialized by the existing component, it is recommend to
use the value {component_name}_DEVICE which gets replaced by the appropriate
address of the selected peripheral for the component. This is automatically done when you
drag and drop the PDD method from the PDD sub-folder of the Peripheral Initialization
component.
Figure 3.30 Peripheral Base Address
Otherwise, the peripheral base addresses can be found in the IO_Map.h file.
PESL (Processor Expert System Library) is dedicated to power programmers, who are
familiar with the microcontroller architecture - each bit and each register. PESL provides
macros to access the peripherals directly. It should be used only in special cases when the
low-level approach is necessary.
PESL is peripheral oriented and complements with Embedded Components, which are
functionality oriented. While Embedded Components provide very high level of project
portability by stable API and inheritance feature across different CPU/DSP/PPC
architectures, PESL is more architecture dependent.
PESL commands grouped by the related peripheral can be found in Processor Expert
Components view in PESL folder.
121
Application Design
Low-level Access to Peripherals
Register access macros are not available for Kinetis and ColdFire+ family
microcontrollers.
The direct control of the Peripheral's registers is a low-level way of creating peripheral
driver which requires a good knowledge of the target platform and the code is typically not
portable to different platform. However, in some cases is this method more effective or
even necessary to use (in the case of special chip features not encapsulated within the
122
Application Design
Low-level Access to Peripherals
Embedded component implementation). Refer to the Low-level Access to Peripherals
topic for details.
The common basic peripheral operations are encapsulated by the PESL library commands
which is effectively implemented using the simple control register writes. Refer to the
Processor Expert System Library topic for details.
123
Application Design
Processor Expert Files and Directories
getReg{w}BitGroupVal (RegName, GroupName) Reads a value of the bits in
group
setReg{w}BitGroupVal (RegName, GroupName, GroupVal ) Sets the group of
the bits to the specified value.
RegName - Register name
BitName - Name of the bit
GroupName - Name of the group
BitMask - Mask of the bit
BitsMask - Mask specifying one or more bits
BitsVal - Value of the bits masked by BitsMask
GroupMask - Mask of the group of bits
GetMask - Mask for reading bit(s)
ClrMask - Mask for clearing bit(s)
SetMask - Mask for setting bit(s)
InvMask - Mask for inverting bit(s)
RegValue - Value of the whole register
BitValue - Value of the bit (0 for 0, anything else = 1)
{w} - Width of the register (8, 16, 32). The available width of the registers depends on
used platform.
Example
Assume that you have a processor which has a PWMA channel and it is required to set
three bits (0,1,5) in the PWMA_PMCTL to 1. Use the following line:
setRegBits(PWMA_PMCTL,35); /* Run counter */
124
Application Design
Static Code Support in Processor Expert
125
Application Design
Static Code Support in Processor Expert
Peripheral Initialization Components covers all MCU peripherals, with exception for
system and bus clock generator peripherals, which are controlled by processor component
as they are part of Processor Expert timing model and their initialization is done during the
startup.
Each Peripheral Initialization Component configures one peripheral and covers all its
features based on the full set of peripheral registers. Peripheral registers are initialized in
the component static initialization method according to component settings represented in
configuration header file which is included in static driver. Refer to the Typical Usage of
Peripheral Initialization Components section for more details about peripheral
initialization component initialization method.
Some additional features associated with the peripheral functionality but controlled by
registers belonging to different peripherals might be also included in component settings,
for example pin routing, interrupts configuration or clock gate control. Such settings lead
to initialization of registers not covered by component itself (refer to the Multiple
Properties Accessing Common Register and <Automatic> Value section for more
information on accessing register from multiple properties). Initialization of these
additional registers is handled by Processor Expert depending on whether Peripheral
Initialization Component covering the registers is present in the project or not:
Project contains Peripheral Initialization Component which covers initialization of
peripheral to which the additional registers belong. In this case, the additional
registers initialization is included in the static initialization method of this
component.
Project doesn't contain Peripheral Initialization Component which would be covering
initialization of additional registers. In such case, Processor Expert takes care of
initialization of registers not covered by any initialization component and generates
appropriate code to the Common_Init() method. User is informed about this by
warning generated by Processor Expert.
For example, application uses Init_ADC component to configure A/D converter with
measurement synchronized with external device connected using pin on chip package.
Routing of the pin involves initialization of General Purpose I/O port A (GPIOA)
peripheral. If Init_GPIO component configuring GPIOA peripheral is in the project
then GPIOA registers involved in Init_ADC pin routing are initialized in the
Init_GPIO static initialization method. If Init_GPIO for GPIOA is not used GPIOA
registers initialization is generated into the Common_Init().
126
Application Design
Static Code Support in Processor Expert
Both modes use shared and project static code repository. Project repository is placed in
the project directory (refer to the Project Static Code Directory Structure for more details)
and shared repository is placed in the Processor Expert installation directory (refer to the
Processor Expert Static Code Repository and Project Repository Synchronization section).
In standalone mode, project repository contains copy of shared repository created during
project creation. In linked mode, project repository links the shared one. It is not possible
to change mode, once it is selected.
Standalone Mode
Complete set of static drivers is stored directly in the project directory. During project
creation, static drivers are copied from shared static code repository to the project
repository. After project is created, it is independent from development environment and
from other projects therefore changes made in static drivers in one project don't affect rest
of the projects.
It is possible to synchronize project's local repository with the common one - Processor
Expert detects changes in the common repository, informs user about them and offers
project local repository update. Also, if static driver is missing in the project directory but
is required by Embedded Component used in the project then Processor Expert offers
adding of the missing files.
Linked Mode
Static drivers are not physically placed in the project directory. Instead, project static code
repository is virtually linked with shared static drivers repository stored in Processor
Expert installation directory. All projects created in this mode shares the same version of
static drivers and any changes made in the shared repository are automatically distributed
across all of the linked projects.
127
Application Design
Static Code Support in Processor Expert
pdd2\{Processor}\peripherals the directory containing all peripheral
initialization modules.
pdd2\{Processor}\system the directory with system and common source
code modules including processor modules.
128
Application Design
Static Code Support in Processor Expert
Configuration header files with parameterization of the static module - header file
name has _Config suffix. Parameterization constant are controlled by component
properties.
Generated component interface header file - header file has the same name as the
component.
129
Application Design
Static Code Support in Processor Expert
Project static code repository: {Project}\Static_Code\Peripherals
Generated modules:
{Peripheral}_Config.h configuration header file contains
{Peripheral}_Init.c module parameterization constants. The constants
reflect settings of the Embedded Component.
{Initialization component name}.h application interface header
file. Intended to be included in the application code to map user-defined initialization
method name with its static implementation. Also contains selected-deviceindependent component-specific peripheral base address constant used as first
parameter of PDD macros. If interrupts are enabled, header also contains component
interrupt subroutine (ISR) declaration.
Generated modules are placed at: {Project}\Generated_Code
130
Application Design
Static Code Support in Processor Expert
PDD_Includes.h the file includes all PDD modules supported for selected
processor. Intended to be included in the application code to access PDD macros. For
more information on PDD, refer to the Physical Device Drivers.
PE_Types.h the file contains common Processor Expert types, constants and
macros implementation.
PE_Error.h the file contains error code constants.
Processor Expert static code repository: {CodeWarrior}\Processor
Expert\lib\{Processor family}\pdd2\{Processor}\system
Project static code repository: {Project}\Static_Code\System
Generated modules:
Vectors_Config.h configuration header file contains Vectors.c module
parameterization constants.
Init_Config.h the file includes all components configuration and interface
header files.
Generated modules are placed in the: {Project}\Generated_Code
IO_Map and System sub-folders are always checked for differences. PDD and
Peripherals sub-folders are checked only if associated Peripheral Initialization
component is in the project. Refer to the Project Static Code Directory
Structure for more information on static code sub-folders.
131
Application Design
Static Code Support in Processor Expert
Components View menu. In this case, all static repository files are showed in the Track
Changes window with their status. Repository synchronization can be used for example to
update project after Processor Expert update or when project should use different
Processor Expert version.
132
Application Design
Internal signals
Internal signals
Internal signals represent interconnections between processor internal peripherals, a
peripheral produces signal which is used by different peripherals. Examples of internal
signals are:
133
Application Design
Internal signals
Trigger signal asserting request (example of trigger source is Program Delay
Block or any timer).
Internal voltage sources internal reference or programmable voltage sources (for
example, produced by D/A converter).
In Processor Expert, each internal signal is represented by name, which is usually
composed of name of peripheral producing the signal and function of the signal. Some
examples are CMP0_output, TMR0_overflow, and DAC6b_output. However, it is
not guaranteed that the same internal signal will have exactly the same representation
across all components. In embedded components, internal signals represented by their
name are typically present on the consumer peripheral side as inputs to the embedded
components. On the signal producer side, internal signal generation control is peripheral
specific.
Some examples of internal signals available on KL25 Kinetis MCU:
Analog comparator input (CMP) peripheral can compare two types of analog signal
sources: external, connected through package pin, or internal, connected using internal
signal. Figure below shows list of sources available for the CMP0 in the
AnalogComp_LDD component.
Figure 3.31 Analog comparator input selection in AnalogComp_LDD
From the list, internal signals are Bandgap (constant voltage reference),
DAC12b0_Output (output of the 12-bit DA converter 0), and DAC6b0_Output
(output of the 6-bit DA converter 0).
Analog-to-digital converter (ADC) trigger A/D conversion can be triggered from the
package pin or from number of internal peripherals. Figure below shows some of the
triggers offered in the ADC_LDD component Trigger input property.
134
Application Design
Internal signals
Figure 3.32 A/D converter trigger selection in ADC_LDD
135
Application Design
Internal signals
Figure 3.33 Timer synchronization trigger selection in Init_TPM
136
Application Design
Internal signals
Figure 3.34 Multiple analog comparator inputs in AnalogComp_LDD
However, Processor Expert offers clear differentiation between internal signals and pins,
as shown in figures below.
Figure 3.35 Pin selection
137
Application Design
Internal signals
Figure 3.36 Internal signal selection
Clear differentiation is possible in property hint. In case of pins, full description of pin
functions along with pin number on processor package is showed. If internal signal is
selected then this fact is signalized at the last line of the hint.
138
Application Design
Internal signals
Figure 3.37 Example of component linking in AnalogComp_LDD
Figure shows AnalogComp_LDD component that uses pin as positive input and internal
signal from 12-bit D/A converter (DAC) output as negative input. Selection of internal
signal causes that Source component property from the negative input group is active and
DAC component is required. User may add new DAC component (DAC_LDD or
Init_DAC in this case) or use DAC_LDD component already present in the project
(component DA1).
139
Application Design
Internal signals
140
4
Processor Expert Tutorials
This tutorial is provided for embedded system designers who wish to learn how to use the
features of Processor Expert. This tutorial will help you to start using Processor Expert for
your own application.
This chapter explains:
Tutorial Project 1 for Kinetis Microcontrollers
141
You can also create a project outside Eclipse workspace. In the Create an
MCU bareboard project page, uncheck the User default location checkbox
and specify the location. This option will allow you to create a project and
generate the code that will be compiled by external compiler and is not
integrated in Eclipse.
3. Select Kinetis K Series > K6x Family > K60D/PK60N512. Click Next.
4. In the Connections page, P&E USB BDM Multilink Universal [FX]/USB Multilink
is set as the default connection. Click Next.
5. In the Language and Build Tool Options page, set C in Languages page. Click
Next.
6. In the Rapid Application Development page, select the Processor Expert from
Rapid Application Development group and click Finish.
The new project is created and ready for adding new components. For adding new
components, refer to the Adding Components topic.
Adding Components
1. In the Components Library view, switch to Alphabetical tab and find a GPIO_LDD
component and from its pop-up menu (invoked by the right mouse button) select Add
to project option.
2. Find TimerUnit_LDD component and from its pop-up menu (invoked by the right
mouse button) select Add to project option.
The components are now visible in the Components folder in the Components view.
Figure 4.1 Component View
142
Configuring Components
1. In the Components view, click GPIO1:GPIO_LDD component to open it in
Component Inspector view.
2. In the Component Inspector view, set the property Field name in the first Bit field
group to LedPin. From the drop-down menu, select the value for Pin as PTA10 (it
corresponds to LED17 on the tower board). Set the Initial pin direction property to
Output. Set Auto initialization to yes.
Figure 4.2 Component Inspector
143
Code Generation
To generate code, in the Project Explorer window, select ProcessorExpert.pe and rightclick on it. Select Generate Processor Expert Code option from the context menu. This
process generates source files for components to the Generated_Code folder in the
CodeWarrior project window. The other modules can be found in the Sources folder.
144
145
146
Index
Symbols
"PESL".h 100
__DI() 103
__EI() 103
__initialize_hardware() 97
_DEVICE 122
_startup() 97
{projectname}_SIGNALS.doc 83
{projectname}_SIGNALS.txt 83
{startupfile}.c 100
Numerics
16-bit Register 103
A
A/D converter 13
Abstraction 55
Access Macros 123
Advanced view 39
AfterNewSpeed 110
Alphabetical 28
Ancestor 84
Assistant 28
B
Bare-metal Applications 58
Basic view 38
BeforeNewSpeed 110
bit 48
bits 48
BitsIO 116
buffer overflow 15
Bus clock 15
ByteIO 116
C
Code Generation 27
Code generation log 99
Code generator 10
ColdFire+ 76
Communication Components 118
Processor Expert User Guide
Component 15
Component Assistant 29
Component Categories 28
Component Driver 15
Component Enabled 27
Component icon 52
Component Inspector 15, 39
Component Inspector View 30
Component module 98
Component sharing 85
Components 125
Components Library 28
Configuration registers 27
PEcfg_ 77
ConnectPin 86
ConnectPin Method 86
Constants 102
Counter 15
CPU.H 78
Creating Applications 14
D
Deinit() 58
Descendant 84
design specifications 10
Design-time verifications 9
DisableEvent 110
Distinct mode 27
Documentation 125
E
Easy Initialization 52
Embedded Components 13
EnableEvent 110
EnterCritical() 103
ERR_ARBITR 105
ERR_BREAK 105
ERR_BUSOFF 104
ERR_BUSY 104
ERR_COMMON 105
ERR_CRC 105
149
ERR_DISABLED 104
ERR_ENABLED 104
ERR_FAILED 105
ERR_FAULT 104
ERR_FRAMING 104
ERR_IDLE 104
ERR_LINSYNC 105
ERR_MATH 104
ERR_NOISE 104
ERR_NOTAVAIL 104
ERR_OK 104
ERR_OVERFLOW 104
ERR_OVERRUN 104
ERR_PARITY 104
ERR_PROTECT 105
ERR_QFULL 105
ERR_RANGE 104
ERR_RXEMPTY 104
ERR_SPEED 104
ERR_TXFULL 104
ERR_UNDERFLOW 105
ERR_UNDERRUN 105
ERR_VALUE 104
Event module 99
Events 14, 15
ExitCritical() 103
Extensible components library 9
Extensible Library 54
External Devices 54
External user module 15
External Xtal frequency 64
F
Filtering 28
fixed value 44
FPGA 8
FPGAs 52
Free running device 15
from interval 45
G
Generated_Code 125
getReg{w}BitGroupVal 124
Graphical IDE 10
150
H
Help on Component 39
Help on component 27
Hertz 48
Hide views 20
High level component 15
High Level Components 55
High speed mode 64
Higher visibility level 38
Hints 51
Hz 48
I
Images 103
Import package 20
Inheritance 84
Init 111
Init() 58
Inspector 26
Inspector - Pinned 26
Inspector Items 35
Internal Peripherals 54
Internal peripherals 16
Interrupt Priority 75, 79
Interrupt Service Routine 73
Interrupt Subroutines 54
Interrupt Vector Table 73
Interrupts 73
Interrupts and Events 73
IO_Map.c 100
IO_Map.h 100, 123
ISR 16, 54
ISRs 24
Items Visibility 38
K
kbit 48
kbits 48
kHz 48
kilohertz 48
Kinetis 76
L
LCF 58
LDD 9, 55
LDD Components 55
LDD components 9, 15, 16
Logical Device Drivers 9, 55
Logical Device Drivers) 15
Low level component 16
Low Level Components 56
Low Power Features 59
Low speed mode 64
M
Macros 102, 103
Main module 99
megahertz 48
Memory 79
Methods 16
methods 14
MHz 48
Microcontroller 16
Microcontroller Unit 16
microseconds 47
milliseconds 47
MK60X256VMD100 141
Modes 28
Module 16
ms 47
N
Named Bits 123
Named Groups of Bits 123
O
On-Chip Peripherals 78
On-chip Peripherals 52
On-chip Peripherals Management 53
OnReset 97
OOP 16
Open File 27
P
PDD 120
PE 16
PE_Const.h 100
PE_Error.h 100
PE_low_level_init() 97
PE_Timer 100
PE_Types.h 100, 123
Peripheral Initialization component 16
Peripheral Initialization Components 56
PESL 16, 122
PESL commands 24
Physical Device Drivers 120
Pin hint 51
Pin_signal 82
Pins 51
PLL 16, 64
Pop-up Menu 28
Popup menu 16
Portability 61
PPG 46, 52
Predefined Types 102
Preferences 21
Prescaler 17
Priority of Event Code 76
Processor 17
Processor Component 15
Processor module 98
Processor ticks 47
Processors 28
Project Options 20
Project Pop-up Menu 20
Properties 17
PWM 46
R
Read Only Items 33
Remove component from project 27
Resources Allocation 85
RTOS 17, 58
RTOS Adapter 58
RTOS environment 58
S
Save Component Settings 27
second 48
151
seconds 47
selectable visibility 38
setReg{w}BitGroupVal 124
Shared Ancestor 84
Shared Drivers 59
Shared mode 27
Shared modules 100
Shared Pins 52
Sharing Pins 85
Show views 20
Signal names 99
Slow speed mode 64
Sources 125
speed mode tabs 47
Speed Modes 81, 116
sub-clock xtal frequency 64
SW 55
system behavior 9
V
Vectors.c 100
View Code 27
View Menu 33
View Mode Buttons 33
X
XML documentation 99
Xtal 17
T
Template 17
Templates 125
testReg{w}BitGroup 123
ticks 47
Timer ticks 47
TimerX 52
TimerX_PPG 52
TimerX_PWM 52
Timing 79
Timing Model 80
Timing Precision Configuration 45
Timing Settings 43, 79
Timing Values Table 45
TWRK60N512 141
Types 102
U
Unused Methods 115
us 47
User module 17
User-defined Component Template 17
152