Processor Expert Software Microcontroller Driver Suite. Device Initialization User Guide

Similar documents
CodeWarrior Plug-in for Freescale HCS12(X) Device Initialization User Manual

Installing Service Pack Updater Archive for CodeWarrior Tools (Windows and Linux) Quick Start

Controller Continuum. for Microcontrollers V6.3. Quick Start

for ColdFire Architectures V7.2 Quick Start

CodeWarrior Development Studio for StarCore DSP SC3900FP Architectures Quick Start for the Windows Edition

CodeWarrior Development Studio for Freescale 68HC12/HCS12/HCS12X/XGATE Microcontrollers Quick Start SYSTEM REQUIREMENTS Hardware Operating System 200

for Freescale MPC55xx/MPC56xx Microcontrollers V2.10 Quick Start

for StarCore DSP Architectures Quick Start for the Windows Edition

CodeWarrior Development Studio for etpu v10.x Quick Start SYSTEM REQUIREMENTS

CodeWarrior Development Tools mwclearcase Plug-in User s Guide

CodeWarrior Development Studio

CodeWarrior Development Studio for Power Architecture Processors Version 10.x Quick Start

Component Development Environment Installation Guide

Model-Based Design Toolbox

3.1. User Guide. Processor Expert and Device Initialization PROCESSOR EXPERT FOR FREESCALE HCS12 & HCS12X FAMILY. Freescale Semiconductor, Inc.

Quick Start Guide for TWR-S08MM128-KIT TOWER SYSTEM MC9S08MM128. The industry s most complete solution for portable medical applications

CodeWarrior Kernel-Aware Debug API

However, if an event comes in when the new value is being written to the pulse accumulator counter, that event could be missed. One solution to this p

Figure 1. Power Barrel Connector Requirements

NOVPEK NetLeap User Guide

Model Based Development Toolbox MagniV for S12ZVC Family of Processors

Getting Started with Pins Tool User's Guide

Interrupts in Decoupled Parallel Mode for MPC5675K Configuration and Usage

3.1. User Guide. Processor Expert and Device Initialization. PROCESSOR EXPERT FOR FREESCALE ColdFire FAMILY. Freescale Semiconductor, Inc.

2005: 0.5 PQ-MDS-PCIEXP

MC56F825x/MC56F824x (2M53V) Chip Errata

CodeWarrior Development Studio for Microcontrollers V10.x Getting Started Guide

Upgrade the Solution With No Changes 2 Upgrade the Solution With No Changes If a Codebase does not contain updates to its properties, it is possible t

Lab Tutorial for TWR-S08MM128-KIT TOWER SYSTEM LAB MC9S08MM128. Electrocardiogram (EKG) with Freescale USB stack

Electrode Graphing Tool IIC Driver Errata Microcontroller Division

Updating the Firmware on USB SPI Boards (KITUSBSPIEVME, KITUSBSPIDGLEVME)

Integrating FreeMASTER-Time Debugging Tool with CodeWarrior for Microcontrollers v10.x Project

MPC8349E-mITX-GP Board Errata

Using the Asynchronous DMA features of the Kinetis L Series

Converting Earlier Versions of CodeWarrior for StarCore DSPs Projects to Version

Using the Project Board LCD Display at 3.3 volts

USB Bootloader GUI User s Guide

MPC7410 RISC Microprocessor Hardware Specifications Addendum for the MPC7410TxxnnnLE Series

Adding a run control interface into an existing CodeWarrior for MCU v10.x project

ColdFire Convert 1.0 Users Manual by: Ernest Holloway

Using IIC to Read ADC Values on MC9S08QG8

Component Development Environment Getting Started Guide

Keil uvision 4 Kinetis Support for Freescale MQX RTOS Release Notes

MPC5200(b) ATA MDMA, UDMA Functionality BestComm Setup Recommendations

Programming and Evaluation Tool for Serial EEPROMs

NovTech User Guide Chameleon96

EchoRemote Evaluation Software for Windows

Using the ColdFire+ Family Enhanced EEPROM Functionality Melissa Hunter Derrick Klotz

56F8300 BLDC Motor Control Application

KIT33972AEWEVBE Evaluation Board

Using the CAU and mmcau in ColdFire, ColdFire+ and Kinetis

Using the Kinetis Family Enhanced EEPROM Functionality

SGTL5000 I 2 S DSP Mode

Apollo2 EVB Quick Start Guide

Symphony SoundBite: Quick Start with Symphony Studio. Installation and Configuration

Use of PGA on MC56F800x Interaction of PDB, PGA and ADC

PQ-MDS-QOC3 Module. HW Getting Started Guide. Contents. About This Document. Required Reading. Definitions, Acronyms, and Abbreviations

Using PE to quickly use common communication interfaces on Kinetis

Vision Toolbox for MATLAB

MTIM Driver for the MC9S08GW64

Using the Knock Window etpu Function

Using the PowerQUICC II Auto-Load Feature

1 Introduction. 2 Problem statement. Freescale Semiconductor Engineering Bulletin. Document Number: EB727 Rev. 0, 01/2010

Design Recommendations to Implement Compatibility Between the MC13783VK and the MC13783VK5

PCB Layout Guidelines for the MC1321x

Technical support for MCUez development tools is available through your regional. For More Information On This Product, Go to:

Mask Set Errata. Introduction. MCU Device Mask Set Identification. MCU Device Date Codes. MCU Device Part Number Prefixes MSE08AZ32_0J66D 12/2002

Software Defined Radio API Release Notes

Using the Multi-Axis g-select Evaluation Boards

Using DMA to Emulate ADC Flexible Scan Mode on Kinetis K Series

etpu General Function Set (Set 1) David Paterson MCD Applications Engineer

Interfacing HCS12 Microcontrollers to the MFR4200 FlexRay Controller

MC33696MODxxx Kit. 1 Overview. Freescale Semiconductor Quick Start Guide. Document Number: MC33696MODUG Rev. 0, 05/2007

56F805. Digital Power Factor Correction using Processor Expert TM Targeting Document. 56F bit Digital Signal Controllers. freescale.

IIC Driver for the MC9S08GW64

Getting Started with the Student Learning Kit Application Module Using the MC9S12DT256 Microcontroller Application Module

Engineering Bulletin. Introduction and Background. Definition of Early TOF EB389/D 11/2001

Getting Started with MCUXpresso SDK CMSIS Packs

CodeWarrior Development Studio for Power Architecture Processors V10.X FAQ Guide

SDR API Linux Installation

Using an External GCC Toolchain with CodeWarrior for Power Architecture

Easy development software from the company that knows MCU hardware best

PAS08QF80 User s Manual

Differences Between the DSP56301, DSP56311, and DSP56321

56F805. BLDC Motor Control Application with Quadrature Encoder using Processor Expert TM Targeting Document. 56F bit Digital Signal Controllers

MPR121 Jitter and False Touch Detection

Migrating from the MPC852T to the MPC875

Mask Set Errata for Mask 5L35K

MC33794 Touch Panel System Using E-Field Sensor Setup Instructions

PAS08QF5264 User s Manual

MCF5445x Configuration and Boot Options Michael Norman Microcontroller Division

MSC8144AMC-S Getting Started Guide

Asymmetric C++ Multicore Application for StarCore DSPs

Mechanical Differences Between the 196-pin MAP-BGA and 196-pin PBGA Packages

16-bit MCU: S12XHY256 Automotive Cluster Demo by: Jose M. Cisneros Steven McLaughlin Applications Engineer Microcontroller Solutions Group, Scotland

Functional Differences Between the DSP56307 and DSP56L307

MCF54451, MCF54452, MCF54453, MCF54454,

Using an I 2 C EEPROM During MSC8157 Initialization

KIT34901EFEVB Evaluation Board

Interfacing MPC5xx Microcontrollers to the MFR4310 FlexRay Controller David Paterson MCD Applications, East Kilbride

Transcription:

Processor Expert Software Microcontroller Driver Suite Device Initialization User Guide Revised: 1 November 2012

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. 2012 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 World Wide Web Technical Support Freescale Semiconductor, Inc. 6501 William Cannon Drive West Austin, TX 78735 U.S.A. http://www.freescale.com/codewarrior http://www.freescale.com/support

Table of Contents 1 Introduction 5 Features and Benefits.............................................. 5 Basic Terms and Definitions......................................... 6 Creating, Configuring, and Generating Code............................ 6 Create an Empty Design......................................... 6 Configure Peripherals........................................... 7 Generate Code................................................. 7 Use the Generated Code......................................... 8 Rapid Application Development Tools................................. 8 Comparison between Processor Expert and Device Initialization......... 8 Device Initialization............................................ 9 Processor Expert.............................................. 10 2 User Interface 11 Processor View.................................................. 11 Work Area................................................... 12 Hints....................................................... 13 Code Generation.............................................. 13 Component Inspector View......................................... 16 Configuration Registers View....................................... 17 3 Using the Tool 21 Peripheral Initialization Components................................. 21 Adding Component............................................ 21 Component Parameters and Device Registers........................ 21 CPU Components............................................. 22 Modifying Component Settings.................................. 22 Code Generation and Usage........................................ 22 Generated Code............................................... 23 Modifying the Generated Code................................... 23 Using the Generated Code....................................... 24 Device Initialization User Guide 3

Table of Contents Defining Interrupt Service Routines..................................24 Interrupt Service Routines Code..................................26 Changing the CPU................................................26 Switching the Project to a different CPU Derivative...................26 Components Assignment........................................27 Converting CodeWarrior Project to use the Device Initialization............27 Index 29 4 Device Initialization User Guide

1 Introduction Device Initialization is a fast, easy, and user-friendly way to configure and generate a CPU peripheral initialization code. This chapter explains: Features and Benefits Basic Terms and Definitions Creating, Configuring, and Generating Code Rapid Application Development Tools Features and Benefits The key features of the Device Initialization tool are: Graphical user interface with CPU package, peripherals, and pins User-friendly access to the initialization setup of the CPU peripherals Initialization code generator You can select Assembly or C format for the generated code Built-in detailed design specifications of the Freescale CPUs Initialization options are automatically transformed into the peripheral control register values Easy to view control register values resulting from the parameter settings. Changes are highlighted Changes in the peripheral control register values are transformed back into the component parameters The key benefits of the Device Initialization tool are: Easy to learn design environment User-friendly names of the peripheral features Easy changes in initialization Possibility to reuse the individual peripheral setup for other designs No need to generate code to see the resulting peripheral control register values Device Initialization User Guide 5

Introduction Basic Terms and Definitions Basic Terms and Definitions Component Peripheral Initialization component is a component that encapsulates initialization of a peripheral. A component can be configured using the Device Initialization dialog box. For more details, refer to the Peripheral Initialization Components section. CPU component Component configuring the CPU core parameters. It cannot be removed from the project. Design All components (the CPU component and the Peripheral Initialization components) with their customized parameters. Device Initialization Window that allows to view and configure parameters of the selected component. Internal peripherals Internal peripherals of the microcontroller (ports, timers, A/D converters, etc. usually controlled by the CPU core using special registers). ISR (Interrupt Service Routine) Code which is called when an interrupt occurs. Module Source code module could be generated by the tool or created by you and included in the project (user module). Peripheral settings Initialization parameters for an individual peripheral. These settings can be saved and restored from the file. Properties Parameters of the component. Property settings define the internal peripheral initialization state that will be converted to generated initialization code during the code generation process. Processor Processor derivative used in a given design. Creating, Configuring, and Generating Code To create a simple design, configure a device, generate initialization code and use it in your application, you have to: 1. Create an Empty Design 2. Configure Peripherals 3. Generate Code 4. Use the Generated Code Create an Empty Design Use the Project Wizard to create a new project. To select the menu command, click File > New > Project >Bareboard Project. 6 Device Initialization User Guide

Introduction Creating, Configuring, and Generating Code Follow the step by step default settings and in the Rapid Application Development Options page, select the Device Initialization option. Click Finish to complete the creation of project. Configure Peripherals To configure peripherals, open the Processor view, Window > Show View > Other > Processor Expert > Processor. The Processor view shows the CPU package with the available internal peripherals. Click the peripheral field to configure its initialization. A new peripheral initialization component is automatically created and the Device Initialization dialog box (Figure 1.2) is displayed. It allows you to view and change the parameters. Figure 1.1 Processor View Initialize the parameters of the peripheral as per your requirement and confirm it by clicking OK button. Use the same steps for all peripherals you wish to setup. Generate Code Click the Generate Code button in the Processor view. In the Basic tab of the Device Initialization dialog box, the default initialization code format is C. Device Initialization User Guide 7

Introduction Rapid Application Development Tools Figure 1.2 Device Initialization Basic Tab Note that on ColdFire CPUs, the assembly code generation is not available. You can specify the name of the output files you wish to generate (you can also keep a default name MCUInit) using the field Generated module name. For more details on generated code, refer to the Code Generation and Usage topic. Use the Generated Code The MCU_init initialization function call is automatically placed at the beginning of the main routine. You can start writing your application code after this initialization function call. Rapid Application Development Tools Two tools are available in the CodeWarrior IDE for rapid application development: Processor Expert and Device Initialization. Both tools have advanced features that lead to accelerate development cycle. Comparison between Processor Expert and Device Initialization The following table shows the features comparison of Processor Expert and Device Initialization. 8 Device Initialization User Guide

Introduction Rapid Application Development Tools Table 1.1 Features Comparison Feature Processor Expert Device Initialization Easy to use graphical IDE Interactive design specifications of Freescale microcontrollers Generated code Peripheral Drivers Initialization code only Generated code languages C C or Assembly Peripheral Init Components Low Level Components High Level Components Project Configurations User-friendly linker parameter file configuration Generated code changes tracking (it is only supported in CodeWarrior and not in Eclipse standalone products) Timing settings in time units (such as seconds and bauds) User components creation Device Initialization User Guide 9

Introduction Rapid Application Development Tools Device Initialization Device Initialization provides a fast and easy way to configure and generate an initialization source code for the CPU. It contains only one set of component, Peripheral Initialization Components. The code initializing the peripheral can be generated for use in Assembler or C. Processor Expert Processor Expert generates drivers in the C language that allows a hardware-independent access to microcontroller peripherals. It contains large library of components called Embedded Components. Embedded Components encapsulate the initialization and functionality of basic elements of embedded systems such as CPU core, CPU on-chip peripherals, standalone peripherals, virtual devices, and pure software algorithms. These facilities are interfaced to the user using properties, methods, and events, such as objects in Object Oriented Programming (OOP). NOTE Processor Expert Embedded Components were formerly called Embedded Beans. Description of the Embedded Components on different levels of abstraction: High Level Components Basic set of components designed carefully to provide functionality to most of the microcontrollers in the market. An application built from these components can be easily ported to another microcontroller supported by the Processor Expert. This group of components can provide comfortable settings of a desired functionality such as time in ms or frequency in Hz, without knowing the details of the hardware registers. Low Level Components Components dependent on the peripheral structure that 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 CPU family offering the appropriate peripheral. However, it is easy to configure device features and use a set of methods and events. Peripheral Initialization Components Components on the lowest level of abstraction. An interface of such components is based on the set of the peripheral control registers. These components cover all features of the peripherals and are designed for initialization of these peripherals. For more details, refer to the Processor Expert user guide. 10 Device Initialization User Guide

2 User Interface The Device Initialization user interface consists of the following windows that are integrated in the CodeWarrior IDE: This chapter explains: Processor View Component Inspector View Configuration Registers View Code Generation Processor View The Processor view is the main window of the Device Initialization design. The window contain the control buttons at the top of the window and working area that allows you to browse and configure the CPU peripherals. To open this window, right-click the CPU component in the project tree and select Target Processor Package. Figure 2.1 CPU Component Pop-up Menu The Processor view is displayed. Device Initialization User Guide 11

User Interface Processor View Figure 2.2 Processor View The view contains the following control buttons: Select CPU package Lists available packages from the current target CPU. From the list of packages, you can choose the one to be used in the design. Refer to the Changing the CPU topic for details. Generate Code Invokes the Code Generation dialog allowing you to generate the initialization code according to the current settings. Refer to the Code Generation and Usage topic for details. General Pop-up Menu This menu appears when you right-click anywhere in the Device Initialization window. It contains the following commands: Zoom in Zoom out Rotate Work Area This area allows you to configure the CPU peripherals by adding the Peripheral Initialization Components. Refer to the Peripheral Initialization Components topic for details. The window shows: Peripherals available on the MCU and their allocation by components Pins and their allocation by components 12 Device Initialization User Guide

User Interface Processor View Useful information that is available in the status line if the mouse cursor is placed on pin, component or peripheral The following information about each pin is displayed on the package: Pin name (either 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 Hints A hint appears when the mouse cursor is placed on a specific item. A pin hint contains: pin number pin name owner of the pin (component that allocates it) short pin description NOTE The pin hint is available only in the package view mode. Component icon hint contains: component type component description Code Generation In the Processor view, for code generation, click Generate Code. You can specify the options influencing the format and placement of the generated code. Options are divided into two groups Basic and Advanced. Device Initialization User Guide 13

User Interface Processor View Figure 2.3 Device Initialization Dialog Box Basic Tab Basic Options The following table explain the Basic options of the Device Initialization dialog box: Table 2.1 Device Initialization Basic Tab Field Description Generated File Type Relocatable Assembler Absolute Assembler C Generates the relocatable code in the assembly language. This option is not available for the absolute assembly projects. Generates an absolute code in assembly language. This option is supported only if it was selected in the CodeWarrior Project wizard. Generates the code in the C language. This option is not available for the assembly projects. After Generation Save and add files to project The files produced by Processor Expert are named using the value of the Generated module name field. The files are automatically added to the Generated Code folder of the Code Warrior project. 14 Device Initialization User Guide

User Interface Processor View Table 2.1 Device Initialization Basic Tab Field Create file and do not add to project Generated module name Description The code will be generated into the newly created untitled editor files. Specifies name of the files where the initialization code will be generated. If this field is empty, the MCUInit.c is used as default value. Advanced Options For advanced settings, click the Advanced tab. Figure 2.4 Device Initalization Advanced Tab Device Initialization User Guide 15

User Interface Component Inspector View The following table explains the Advanced options of the Device Initialization dialog box: Table 2.2 Device Initalization Advanced Tab Field Generate register modification only if initialization value does not match reset state Generate comments about register modification Generate interrupt vector table Generate interrupt service routine templates Generate initialization of registers writable only once Generate initialization of register placed in FLASH Description This option does not affect the registers writable only once (for example CONFIGx) nor the registers placed in FLASH (for example MORx). Source code will contain comments with descriptions of the register values. Interrupt vector table content will be generated to the output file. Tool will generate an empty interrupt routine definitions for all enabled interrupts according to the component parameters. For more details, refer to the Defining Interrupt Service Routines topic. These registers can be written only once after reset due to technological or safety reasons. This option enables the generation of initialization code for these registers. Initialization of these registers will be done during the programming of the application code to the FLASH memory. Common Option Show this dialog every time before code generation Using this checkbox, you can enable or disable appearance of this dialog box before every code generation. Component Inspector View Component Inspector allows to view and edit attributes of the item selected in the Project Explorer. To open this vew, click Window > Show View > Other... and select Processor Expert > Components Inspector. Inspector window contains the three columns: 16 Device Initialization User Guide

User Interface Configuration Registers View Name Name of the item to be selected. Groups of items may be collapsed or expanded by double clicking on the first line of the group with its name, it has '+' or '- ' sign on the left. Value the settings of the items are made in this column. For list of item types, refer to the Inspector Items topic for details. Details the current setting or an error status may be reflected on the same line, in the rightmost column of the inspector. The view allows you to modify parameters of components configuring internal peripherals of the processor. For more details on the peripheral components, refer to the Peripheral Initialization Components topic. Figure 2.5 Component Inspector View A parameter can be presented as read-only and you cannot change its content. Such readonly values are shown in gray. View Mode buttons are placed at the top of the window (Basic, Advanced, Expert). These buttons allow you to switch complexity of the view of the component's items. Configuration Registers View This view displays the values of the individual control registers that is set by a generated initialization code. It shows values of individual control or data registers related to the currently selected CPU peripheral. On some peripherals, there may be present an Additional Registers section within this panel that lists the registers that are initialized, but belong to a different peripheral. Device Initialization User Guide 17

User Interface Configuration Registers View Figure 2.6 Configuration Registers View The following table describe the fields of Configuration Registers view: Table 2.3 Register Details Field Description Peripheral Registers Name Specifies name of the register according to the CPU datasheet. 18 Device Initialization User Guide

User Interface Configuration Registers View Table 2.3 Register Details Field Init. value Address Additional Registers Description Specifies the initialization value of a register or bit computed according to the settings in the Component Parameters panel. This is the last value written by the initialization function to the register. For some registers, the value read from the register can be different than the last written value. For example, some interrupt flags are cleared by writing 1. Refer to the MCU manual for details on registers behavior. If the row is active, the value can be changed using the keyboard. The field also contains a radix button (H,D,B) that allows to switch between Hexadecimal, Decimal and Binary formats of the value. The value that contains undefined bits is always shown in binary format. Specifies address of a register. These rows can be unfolded under each register contain values and the names of individual bits. Bits are sorted from the highest to lowest weight. The bit rows of a register can be shown or hidden using the plus/minus icons. Device Initialization User Guide 19

User Interface Configuration Registers View 20 Device Initialization User Guide

3 Using the Tool This chapter describes the basic principles and tasks related to device initialization. This chapter explains: Peripheral Initialization Components Code Generation and Usage Defining Interrupt Service Routines Changing the CPU Converting CodeWarrior Project to use the Device Initialization Peripheral Initialization Components A Peripheral Initialization Component is an object that provides a interface to the initialization parameters of a selected on-chip CPU peripheral. Parameters of the Peripheral Initialization Component represent the settings of all peripheral registers in the tabular form. Names of the Peripheral Initialization Components are Init_<peripheral> and they are specific for each CPU family. Adding Component Components can be added to the design using the Processor view. Click on the unallocated peripheral to add a new component. The new component is preset to work with the selected device. Device Initialization dialog box allows you to configure parameters of the component. For information, refer to the Component Inspector View topic. Component Parameters and Device Registers Every component contains a group of parameters (properties) that describe the desired initialization state of the device. These parameters are automatically transformed to values of control registers related to the selected peripheral. Device Initialization dialog box shows both component parameters and their register values. For information, refer to the Component Inspector View topic. Device Initialization User Guide 21

Using the Tool Code Generation and Usage Component parameters are grouped to several groups by type. The following groups are commonly present in peripheral initialization components: Settings Common peripheral parameters Pins Configuration of the pins related to the peripheral Interrupts Configuration of the interrupts and interrupt service routines related to the peripheral (for details, refer to the Defining Interrupt Service Routines topic) Initialization Parameters related to the peripheral initialization CPU Components A CPU component is the component that configures the parameters of the CPU core such as clock source, frequency, and power-saving capabilities. The CPU component is present in design and cannot be removed. CPU component contains the following parameter groups: Clock Settings Configuration of the CPU timing Internal Resource Mapping Configuration of the memory mapping of CPU resources, for example, interrupt vector table Internal Peripherals Configuration of the peripherals not supported by separate components and settings that can be shared among components CPU Interrupts Configuration of the interrupts related to the CPU core Modifying Component Settings Parameters of existing components can be configured using the Device Initialization dialog box which can be opened by clicking on the component's icon in the Processor view. Code Generation and Usage Start the code generation. To generate code: 1. In the Processor view, click Generate Code. The Device Initialization dialog box with the code generation option appears. For more details, refer to the Code Generation topic. 2. In the Device Initialization dialog box, click Generate. The source code initializing the MCU registers according to the specified component parameters is generated. The generated modules are added into the project and can be found in the Sources subfolder of the project. 22 Device Initialization User Guide

Generated Code Using the Tool Code Generation and Usage During the code generation process, the Device Initialization tool generates the initialization code for the CPU peripherals allocated by the components. The generated code reflects the configuration of the components' parameters and is contained in the function named MCU_init. You should call this function at the beginning of the application code to initialize the peripherals. In the ColdFireV1, an additional function is generated, named initialize_hardware. It contain settings of the clock source, the core registers, and the system control registers (SOPTx, SPMSCx, all write-once registers). This function is called from the after-reset startup code. The generated module consists of two files: Implementation file containing the code of the initialization function(s) and optionally the interrupt vectors table. Interface file containing the declarations that can be referenced by the user. This file is generated only if After Generation option is set to Save and add files to project. Depending on the After generation option, the files can be stored to a disk and added to the current project or just shown in the editor as untitled files. For details, refer to the Code Generation topic. Device Initialization tool can generate the following types of initialization code: Relocatable Assembler The implementation file has the extension.asm and the interface file has the extension.inc. This option is not available for the absolute assembly projects. Absolute Assembler The implementation file has the extension.inc and must be included at the end of the user module, where address for code is selected (using ORG). Absolute assembler is supported only if it was selected in the CodeWarrior Project wizard. C language The implementation file has the extension.c and the interface file has the extension.h. A default name for the generated module is MCUInit. An initialization code format, the generated module name, and other code generation options, can be configured in the Device Initialization dialog box. For details, refer to the Code Generation topic. Modifying the Generated Code If the content of generated modules is written to the disk, it always overwrites the existing files during every code generation. As a result all the user modification are discarded with the following exceptions: user definitions (or generally any other source code) in.c (or.asm) placed in the special comment marks. In case of C language it looks like: Device Initialization User Guide 23

Using the Tool Defining Interrupt Service Routines /* User declarations and definitions */ User source code... /* End of user declarations and definitions */ content of interrupt service routines that are assigned to any interrupt(s) in the peripheral initialization components. For details, refer to the Defining Interrupt Service Routines topic. unused interrupt service routines (no component contains their name). They do not disappear, but they are moved to the end of file. The generated comments before and after the ISR must not be modified for this feature to work properly. NOTE All the changes done in the.h file (or.inc in case of assembly language) are preserved. The file is always overwritten. Using the Generated Code To call MCU_init function from the main file, it is necessary to do the following modification in your code: Device initialization by default generates an interrupt vector table containing all interrupt vectors (it can be disabled in the Device Initialization dialog box, refer to the Code Generation topic for details). Existing interrupt vector definitions should be removed or commented out to avoid a conflict. On the derivatives from the RS08 family, the interrupt support is missing or is limited. For details, refer to the Defining Interrupt Service Routines topic. For details on configuring interrupt vectors, refer to the Defining Interrupt Service Routines topic. Add a call to the generated MCU_init function at the beginning of the application main routine. The new project already have this line. NOTE The prototype or external declaration of the MCU_init function or a command including the interface file with this declaration should be present in the module where the MCU_init is called. In a new project, it is already there in the main file. Defining Interrupt Service Routines Some peripheral initialization components allow the initialization of an interrupt service routine. Interrupt(s) can be enabled in initialization code using appropriate parameters that can be found within the group interrupts. If an interrupt is enabled, it is necessary to enter 24 Device Initialization User Guide

Using the Tool Defining Interrupt Service Routines a name for the ISR into the ISR name parameter. This name is used in the Interrupt Vector table during the code generation process. Refer to the Code Generation and Usage topic for details. Note that even if the Interrupt property is disabled, the ISR name is still being generated into the Interrupt Vector table. Figure 3.1 Example of the Interrupt Setup You can enable or disable peripheral interrupts in the code during the runtime. Version specific information for RS08 family Derivatives of the RS08 family with CPU core version 2 support a single global interrupt vector. The interrupt doesn t support a vector table lookup mechanism as used on HC(S)08 devices. It is the responsibility of a routine servicing the global interrupt to poll the system interrupt pending registers (SIPx) to determine if an interrupt is pending. To support the single global interrupt vector there is a set of emulated interrupt vectors for each HW module defined. User can assign an interrupt service routine to these emulated interrupt vectors in a component. To emulate the interrupt vector table mechanism of the HCS08 family a global interrupt vector routine is generated, which performs check of the SIPx registers to determine if an interrupt is pending and calls appropriate interrupt service routines. The order in which the SIPx registers are polled is affected by priority of the emulated interrupts. The priority can be in the range 0.. number_of_interrupts-1 (e.g. 0.. 15). Default priority value depends on the position of an associated bit in a SIPx register. The interrupt priority can be changed to any value within the allowed range. The lower is the number, the higher is the priority because the interrupts with a lower priority number are polled first. When two interrupts are assigned the same priority then the order in which they are polled depends on the default priority. Device Initialization User Guide 25

Using the Tool Changing the CPU Interrupt Service Routines Code The ISR with the specified name has to be declared according to the compiler conventions and fully implemented by you. Declarations of the ISRs that do not exist yet can be generated automatically during the code generation process into the generated module if the option Generate interrupt service routine templates is enabled. For details, refer to the Code Generation topic. Version specific information for RS08 family: All ISR on the RS08 family has to be defined as ordinary C functions (or assembly routines) because they are called from global interrupt handler that emulates individual interrupt functionality. The user code inside ISR is not touched during the code generation, in case the ISR is used for an interrupt. In case, the interrupt service routine is not assigned to any interrupt, it is moved to the end of file. WARNING! You should synchronize ISR names in the code and ISR names specified in components. If an ISR is renamed, the name has to be changed in the component(s) where this ISR name is assigned and vice versa. This has to be done before next code generation. Otherwise, the newly specified ISR would not be found and the existing ISR with an old name will be treated as unassigned and it will be moved to the end of file. Changing the CPU The type of the CPU package can be changed using the Select CPU Package button in the Processor view. For details, refer to the Processor View topic. Switching the Project to a different CPU Derivative To switch to a different CPU derivative for the project, select Project Change MCU/ Connection from the menu bar in the CodeWarrior IDE. 26 Device Initialization User Guide

Using the Tool Converting CodeWarrior Project to use the Device Initialization Components Assignment If some peripherals of the MCU set by components are not supported by the new MCU derivative the project is switched to, a dialog box with a list of the unsupported items is shown. You are asked to confirm that these items will be removed from the design. Converting CodeWarrior Project to use the Device Initialization This topic guides you through a conversion from a C or C++ project to the project using the device initialization and a peripheral initialization code generated by this tool. WARNING! Note that in most cases this conversion involves necessary manual changes in the application code. For example, the definition of register interrupt vectors table created by you often conflicts with the definitions of device initialization. Do not forget to backup the whole project before the conversion. Some files will have to be removed from the project. The conversion is recommended for experienced users only. To convert C/C++ project: 1. Select the menu command File > New > Other... 2. In the Select a wizard dialog box, select Processor Expert > Enable Processor Expert for Existing C Project and click Next. Figure 3.2 Select a Wizard Page Device Initialization User Guide 27

Using the Tool Converting CodeWarrior Project to use the Device Initialization 3. Select the project (C/C++) that you would like to convert; also select the Project Type as Device Initialization and click Next. Figure 3.3 Enable Processor Expert for Existing C Project Page 4. Select the MCU that the project is designed for. Figure 3.4 Processor Expert Project Page 28 Device Initialization User Guide

Using the Tool Converting CodeWarrior Project to use the Device Initialization 5. Select the desired target compiler from the list and Processor Expert configurations that you would like to have in the project. Click Next. 6. Review the actions that Processor Expert is about to perform. You can uncheck the checkboxes for items you would like not to be done. Ensure that you have backed-up your project before you click Finish. Figure 3.5 Enable Processor Expert for Existing C Project Page 7. Add a call to the generated MCU_init function at the beginning of main routine of the application. For details, refer to the Code Generation and Usage topic. 8. For Kinetis family projects, it is necessary to remove the files kinetis_sysinit.c and kinetis_sysinit.h from Project_Settings/Startup_Code. This module contains definitions that conflict with Processor Expert definitions. Device Initialization User Guide 29

Using the Tool Converting CodeWarrior Project to use the Device Initialization 30 Device Initialization User Guide

Index A Absolute Assembler 23 Adding Component 21 Advanced Options 15 B Basic Options 14 C C language 23 Changing the CPU 26 Clock Settings 22 Code Generation 22 Code Generation Options 13 Common Options 16 Component 6 Component Parameters 21 CPU component 6 CPU Components 22 CPU Interrupts 22 D Defining Interrupt Service Routines 24 Design 6 Device Initialization 6, 9 Device Registers 21 E Empty Design 6 G Generate Code 12 Generated Code 23 H High Level Components 10 Hints 13 I Implementation file 23 Init_ 21 Initialization 22 Inspector Dialog Box 16 Interface file 23 Internal Peripherals 22 Internal peripherals 6 Internal Resource MappingI 22 Interrupt Service Routines Code 26 Interrupts 22 ISR 6 L Low Level Components 10 M Modifying Components Settings 22 Module 6 P Peripheral Initialization Components 10, 21 Peripheral settings 6 Pins 22 Processor 6 Processor Expert 10 Properties 6 R Relocatable Assembler 23 S Select CPU package 12 Settings 22 U User Changes 23 W Work Area 12 Device Initialization User Guide 29

30 Device Initialization User Guide