Book Image

ARM® Cortex® M4 Cookbook

By : Mark Fisher, Dr. Mark Fisher
Book Image

ARM® Cortex® M4 Cookbook

By: Mark Fisher, Dr. Mark Fisher

Overview of this book

Embedded microcontrollers are at the core of many everyday electronic devices. Electronic automotive systems rely on these devices for engine management, anti-lock brakes, in car entertainment, automatic transmission, active suspension, satellite navigation, etc. The so-called internet of things drives the market for such technology, so much so that embedded cores now represent 90% of all processor’s sold. The ARM Cortex-M4 is one of the most powerful microcontrollers on the market and includes a floating point unit (FPU) which enables it to address applications. The ARM Cortex-M4 Microcontroller Cookbook provides a practical introduction to programming an embedded microcontroller architecture. This book attempts to address this through a series of recipes that develop embedded applications targeting the ARM-Cortex M4 device family. The recipes in this book have all been tested using the Keil MCBSTM32F400 board. This board includes a small graphic LCD touchscreen (320x240 pixels) that can be used to create a variety of 2D gaming applications. These motivate a younger audience and are used throughout the book to illustrate particular hardware peripherals and software concepts. C language is used predominantly throughout but one chapter is devoted to recipes involving assembly language. Programs are mostly written using ARM’s free microcontroller development kit (MDK) but for those looking for open source development environments the book also shows how to configure the ARM-GNU toolchain. Some of the recipes described in the book are the basis for laboratories and assignments undertaken by undergraduates.
Table of Contents (16 chapters)
ARM Cortex M4 Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Installing uVision5


A free evaluation version of the IDE known as the MDK-ARM Lite edition, running (albeit with limited functionality) under the Windows operating system, is available for download. The main limitation of the environment is that programs that generate more than 32 KB of code cannot be compiled and linked (see http://www.keil.com/demo/limits.asp). However, since most programs written by novices tend be quite small, this limitation is not a serious problem. For those who expect their executable image to exceed 32 KB, other open source compiler and IDE options are considered in Chapter 9, Embedded Toolchain.

uVision5, the latest version of the IDE is distributed as two components. An MDK core contains all the development tools, and software packs, together with Cortex Microcontroller Software Interface standard (CMSIS) and middleware libraries, which add support for target devices.

Installation involves downloading and running an executable (.exe) file. Users can download and install the latest version after first registering their contact details at http://www2.keil.com/mdk5/install/.

How to do it…

  1. Download the latest version of the software by following the instructions provided by Keil. Device-specific libraries are not included in installations from version 5 onwards, so at the end of the installation, we must configure the IDE using the Pack Installer to choose the resources (that is target devices, boards, and examples) that we need.

  2. Select the Boards tab, choose the MCBSTM32F400 Keil evaluation board featuring the STM32F407IGHx STMicroelectronics part, as this is the target for all the practical examples described in this cookbook.

  3. With the Packs tab, in addition to the default installation options: CMSIS and Keil ARM Processional Middleware for ARM Cortex-M-based devices, board support for MCBSTM32F400 is also needed. Select the latest version Keil::32F4xx_DFP (2.6.0).

  4. Select the Examples tab, and copy the board-specific example programs to a convenient local folder. Note: the example programs illustrate many useful features of the evaluation board, and are an invaluable resource.

  5. Once we have downloaded and installed MDK-ARM uVision5, the IDE can be invoked from the Windows Taskbar. If we wish to update the installation, the pack installer can be invoked by selecting the pack installer icon on uVision5 toolbar.

  6. We demonstrate the basic features of uVision in this chapter, but later on, we'll probably need to access the uVision user guide via the Help menu (also available at http://www2.keil.com/mdk5) to learn about the more advanced features of the IDE. A useful guide to getting started with uVision5 can be found at https://armkeil.blob.core.windows.net/product/mdk5-getting-started.pdf. An overview of uVision5 is available at http://www2.keil.com/mdk5, and this includes some video clips that describe the design philosophy, and explain how to use the Pack Installer and create a new project.

How it works…

Computer programming involves specifying a sequence of binary codes that are interpreted by the machine as instructions that together enable it to undertake some task. The instruction sets of early computers were small and easily memorized by programmers, so programs were written directly in machine code, and each instruction code word was set up on switches and written to memory. Finally, once all the instructions had been entered, the program was executed. With the development of more powerful machines and larger instruction sets, this approach became unworkable. This motivated the need to program in higher level (human understandable) languages that are translated into machine code by a special program called a compiler. Modern day programmers rarely need to interpret individual binary codes; instead, they use a text editor to enter a sequence of high-level language statements, a compiler to convert them into machine code, a linker to allow programs to reuse previously written (library) code, and a loader to write the binary codes to memory. The steps comprising edit, compile, link, load can be undertaken by running each program (editor, compiler, linker, loader) separately. However, nowadays they are usually packaged together within a wrapper called an IDE. Some IDEs are language-specific and some are customizable, allowing developers to create bespoke programming environments for any target language and/or machine.

The pack installer framework allows MDK-ARM uVision5 to be customized and extended to target a large number of devices and evaluation boards using ARM cores. But while, IDEs represent the most popular and efficient route to programming, uVision represents just one of a number of IDEs that are widely available. Other manufacturers and open source communities offer alternatives, some of which we investigate later in the book.