6 Contents Contents Preface.. .3 Document Conventions..... .5 0 ntents… Chapter 1.Introduction..... .9 Last-Minute Changes........ 11 Licensing. 11 nstallation.… 11 Requesting Assistance........... 13 Chapter 2.Microcontroller Architectures......14 Selecting an Architecture....... 15 Classic and Extended 8051 Devices........ .17 Infineon C166.XE166.XC2000 20 ARM7 and ARM9 based Microcontrollers 21 Cortex-Mx based Microcontrollers 23 Code Comparison.............. 26 Generating Optimum Code 28 Chapter 3.Development Tools.... .33 Software Development Cycle 33 μVision IDE. .34 u Vision Device Database 35 μVision Debugger.… 3 Assembler..... 37 C/C++Compiler.… 38 Object-HEX Converter 38 Linker/Locator.... 39 Library Manager 39 Chapter 4.RTX RTOS Kernel.. 40 Software Concepts............. 40 RTX Introduction..… 43 Chapter5.UsingμVision… .55 Menus.… 59 Toolbars and Toolbar Icons 63 Project Windows............. 69
6 Contents Contents Preface ................................................................................................................... 3 Document Conventions ........................................................................................ 5 Contents ................................................................................................................ 6 Chapter 1. Introduction...................................................................................... 9 Last-Minute Changes ....................................................................................... 11 Licensing .......................................................................................................... 11 Installation ....................................................................................................... 11 Requesting Assistance ..................................................................................... 13 Chapter 2. Microcontroller Architectures ...................................................... 14 Selecting an Architecture ................................................................................. 15 Classic and Extended 8051 Devices ................................................................ 17 Infineon C166, XE166, XC2000 ..................................................................... 20 ARM7 and ARM9 based Microcontrollers ...................................................... 21 Cortex-Mx based Microcontrollers .................................................................. 23 Code Comparison ............................................................................................ 26 Generating Optimum Code .............................................................................. 28 Chapter 3. Development Tools ......................................................................... 33 Software Development Cycle .......................................................................... 33 µVision IDE ..................................................................................................... 34 µVision Device Database ................................................................................ 35 µVision Debugger ............................................................................................ 35 Assembler ........................................................................................................ 37 C/C++ Compiler .............................................................................................. 38 Object-HEX Converter .................................................................................... 38 Linker/Locator ................................................................................................. 39 Library Manager .............................................................................................. 39 Chapter 4. RTX RTOS Kernel ........................................................................ 40 Software Concepts ........................................................................................... 40 RTX Introduction ............................................................................................. 43 Chapter 5. Using µVision ................................................................................. 55 Menus .............................................................................................................. 59 Toolbars and Toolbar Icons ............................................................................. 63 Project Windows .............................................................................................. 69
Getting Started:Creating Applications with uVision 7 Editor Windows............. Output Windows.… 73 Other Windows and Dialogs..... 74 On-line Help............ 74 Chapter 6.Creating Embedded Programs .75 Creating a Project File 75 Using the Project Windows....... 77 Creating Source Files....... 78 Adding Source Files to the Project 79 Using Targets,Groups,and Files. 79 Setting Target Options............. 81 Setting Group and File Options 82 Configuring the Startup Code.. 83 Building the Project............ 84 Creating a HEX File 85 Working with Multiple Projects 86 Chapter 7.Debugging..... 89 Simulation...... 91 Starting a Debug Session 91 Debug Mode........... 93 Using the Command Window.... 9 Using the Disassembly Window. 94 Executing Code....... 95 Examining and Modifying Memory .96 Breakpoints and Bookmarks.... 98 Watchpoints and Watch Window 100 Serial I/O and UARTs....... 102 Execution Profiler 103 Code Coverage........ 104 Performance Analyzer 105 Logic Analyzer 106 System Viewer...... 107 Symbols Window............ 108 Browse Window 109 Toolbox.... 110 Instruction Trace Window 111 Defining Debug Restore Views 111
Getting Started: Creating Applications with µVision 7 Editor Windows ............................................................................................... 71 Output Windows .............................................................................................. 73 Other Windows and Dialogs ............................................................................ 74 On-line Help .................................................................................................... 74 Chapter 6. Creating Embedded Programs ..................................................... 75 Creating a Project File ..................................................................................... 75 Using the Project Windows ............................................................................. 77 Creating Source Files ....................................................................................... 78 Adding Source Files to the Project .................................................................. 79 Using Targets, Groups, and Files ..................................................................... 79 Setting Target Options ..................................................................................... 81 Setting Group and File Options ....................................................................... 82 Configuring the Startup Code .......................................................................... 83 Building the Project ......................................................................................... 84 Creating a HEX File ........................................................................................ 85 Working with Multiple Projects ...................................................................... 86 Chapter 7. Debugging ....................................................................................... 89 Simulation ........................................................................................................ 91 Starting a Debug Session ................................................................................. 91 Debug Mode .................................................................................................... 93 Using the Command Window .......................................................................... 94 Using the Disassembly Window ...................................................................... 94 Executing Code ................................................................................................ 95 Examining and Modifying Memory ................................................................ 96 Breakpoints and Bookmarks ............................................................................ 98 Watchpoints and Watch Window .................................................................. 100 Serial I/O and UARTs.................................................................................... 102 Execution Profiler .......................................................................................... 103 Code Coverage ............................................................................................... 104 Performance Analyzer ................................................................................... 105 Logic Analyzer .............................................................................................. 106 System Viewer ............................................................................................... 107 Symbols Window ........................................................................................... 108 Browse Window ............................................................................................ 109 Toolbox .......................................................................................................... 110 Instruction Trace Window ............................................................................. 111 Defining Debug Restore Views ..................................................................... 111
8 Contents Chapter 8.Using Target Hardware........... 112 Configuring the Debugger...... .113 Programming Flash Devices 114 Configuring External Tools 115 Using ULINK Adapters.… 116 Using an Init File...... 121 Chapter 9.Example Programs........ …122 “Hello”Example Program… .123 "Measure"Example Program 127 “Traffic'”Example Program. 138 “Blinky”Example Program 142 Glossary …146 Index... 151
8 Contents Chapter 8. Using Target Hardware............................................................... 112 Configuring the Debugger ............................................................................. 113 Programming Flash Devices .......................................................................... 114 Configuring External Tools ........................................................................... 115 Using ULINK Adapters ................................................................................. 116 Using an Init File ........................................................................................... 121 Chapter 9. Example Programs ...................................................................... 122 “Hello” Example Program ............................................................................. 123 “Measure” Example Program ........................................................................ 127 “Traffic” Example Program ........................................................................... 138 “Blinky” Example Program ........................................................................... 142 Glossary ............................................................................................................ 146 Index .................................................................................................................. 151
Getting Started:Creating Applications with uVision 9 Chapter 1.Introduction Thank you for allowing Keil to provide you with software development tools for your embedded microcontroller applications. This book,Getting Started,describes the u Vision IDE,u Vision Debugger and Analysis Tools,the simulation,and debugging and tracing capabilities.In addition to describing the basic behavior and basic screens of uVision,this book provides a comprehensive overview of the supported microcontroller architecture types,their advantages and highlights,and supports you in selecting the appropriate target device.This book incorporates hints to help you to write better code.As with any Getting Started book,it does not cover every aspect and the many available configuration options in detail.We encourage you to work through the examples to get familiar with uVision and the components delivered. The Keil Development Tools are designed for the professional software developer,however programmers of all levels can use them to get the most out of the embedded microcontroller architectures that are supported. Tools developed by Keil endorse the most popular microcontrollers and are distributed in several packages and configurations,dependent on the architecture. MDK-ARM:Microcontroller Development Kit,for several ARM7,ARM9, and Cortex-Mx based devices PK166:Keil Professional Developer's Kit,for C166,XE166,and XC2000 devices DK251:Keil 251 Development Tools,for 251 devices PK51:Keil 8051 Development Tools,for Classic Extended 8051 devices In addition to the software packages,Keil offers a variety of evaluation boards, USB-JTAG adapters,emulators,and third-party tools,which completes the range of products The following illustrations show the generic component blocks of u Vision in conjunction with tools provided by Keil,or tools from other vendors,and the way the components relate
Getting Started: Creating Applications with µVision 9 Chapter 1. Introduction Thank you for allowing Keil to provide you with software development tools for your embedded microcontroller applications. This book, Getting Started, describes the µVision IDE, µVision Debugger and Analysis Tools, the simulation, and debugging and tracing capabilities. In addition to describing the basic behavior and basic screens of µVision, this book provides a comprehensive overview of the supported microcontroller architecture types, their advantages and highlights, and supports you in selecting the appropriate target device. This book incorporates hints to help you to write better code. As with any Getting Started book, it does not cover every aspect and the many available configuration options in detail. We encourage you to work through the examples to get familiar with µVision and the components delivered. The Keil Development Tools are designed for the professional software developer, however programmers of all levels can use them to get the most out of the embedded microcontroller architectures that are supported. Tools developed by Keil endorse the most popular microcontrollers and are distributed in several packages and configurations, dependent on the architecture. MDK-ARM: Microcontroller Development Kit, for several ARM7, ARM9, and Cortex-Mx based devices PK166: Keil Professional Developer’s Kit, for C166, XE166, and XC2000 devices DK251: Keil 251 Development Tools, for 251 devices PK51: Keil 8051 Development Tools, for Classic & Extended 8051 devices In addition to the software packages, Keil offers a variety of evaluation boards, USB-JTAG adapters, emulators, and third-party tools, which completes the range of products. The following illustrations show the generic component blocks of µVision in conjunction with tools provided by Keil, or tools from other vendors, and the way the components relate
10 Chapter 1.Introduction Software Development Tools Like all software based on Keil's u Vision IDE, the toolsets provide a powerful,easy to use and Software Development Tools easy to learn environment for developing embedded applications. C/C++Compiler They include the components you need to create, RTX RTOS Kernel Library debug,and assemble your C/C++source files, uVision and incorporate simulation for microcontrollers IDE Device Database and related peripherals. μ/ision Debugger Analysis Tools The RTX RTOS Kernel helps you to implement complex and time-critical software. Complete Device Simulation RTOS and Middleware Components These components are designed to solve RTOS and Middleware communication and real-time challenges of Components embedded systems.While it is possible to implement embedded applications without using RTX RTOS Source Code a real-time kernel,a proven kernel saves time and shortens the development cycle. TCPnet Networking Suite This component also includes the source code Flash File System files for the operating system. USB Device Interface CAN Interface Hardware Debug Adapters The u Vision Debugger fully supports several emulators provided by Keil,and other vendors. The Keil ULINK USB-JTAG family of adapters ☒KEIL ULINK A con nect the USB port of a PC to the target hardware.They enable you to download,test. and debug your embedded application on real hardware
10 Chapter 1. Introduction C/C++ Compiler RTX RTOS Kernel Library µVision IDE & Device Database µVision Debugger & Analysis Tools Complete Device Simulation Software Development Tools RTX RTOS Source Code TCPnet Networking Suite Flash File System USB Device Interface CAN Interface RTOS and Middleware Components Software Development Tools Like all software based on Keil’s µVision IDE, the toolsets provide a powerful, easy to use and easy to learn environment for developing embedded applications. They include the components you need to create, debug, and assemble your C/C++ source files, and incorporate simulation for microcontrollers and related peripherals. The RTX RTOS Kernel helps you to implement complex and time-critical software. RTOS and Middleware Components These components are designed to solve communication and real-time challenges of embedded systems. While it is possible to implement embedded applications without using a real-time kernel, a proven kernel saves time and shortens the development cycle. This component also includes the source code files for the operating system. Hardware Debug Adapters The µVision Debugger fully supports several emulators provided by Keil, and other vendors. The Keil ULINK USB-JTAG family of adapters con nect the USB port of a PC to the target hardware. They enable you to download, test, and debug your embedded application on real hardware