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

Linking an evaluation board


This book focuses on the Keil STM32F400 evaluation board that features a STM32F407IGHx STMicroelectronics part to illustrate practical work. A wide range of other evaluation boards are available, and many of these are supported by the uVision5 IDE (that is, using the pack installer to download appropriate software components).

How to do it…

  1. Once we have installed uVision, linking the evaluation board is simply a matter of connecting the two USB cables shown in the following image to your PC. The small daughter board shown in the image is Keil's ULINK-ME debug adaptor (http://www.keil.com/ulinkme/) that provides the data connection.

    Tip

    The Windows plug-and-play feature will automatically find and install the driver (downloaded with uVision5).

  2. The second USB cable provides power. Evaluation boards can usually be powered by a laptop or PC host connected via the USB port, but some laptop PSUs may be unable to supply sufficient current, and a USB hub might be required. Alternatively, an external supply can be connected via a separate power plug.

    Note

    The first time the ULINK device is used, its firmware needs to be configured. The configuration depends on the MDK version, and if we wish to use different versions of the MDK (that is, perhaps because we have legacy code developed using uVision4) then the ULINK configuration may need to be erased. http://www.keil.com/support/docs/3632.htm provides some further information and a download utility for this purpose.

How it works…

A USB-Link adaptor is needed to enable the executable code produced by the IDE to be uploaded to the evaluation board. The adaptor supports a Joint Test Action Group (JTAG) interface on the evaluation board, and offers a number of debugging possibilities (depending on the type of adaptor used). There are several debug adaptor connection options. Firstly, the Keil ULINK-ME debug adaptor (http://www.keil.com/ulinkme/), packaged together with the board as a starter kit, connects to the 20-pin JTAG connector and supports serial wire programming and on-chip debugging. Keil's ULINK-2 adaptor (http://www.keil.com/ulink2/) represents a more robust solution with similar functionality, and ULINK-Pro (http://www.keil.com/ulinkpro/) offers extended debug facilities employing high-speed streaming trace technology.

There's more…

The MCBSTM32F400 (http://www.keil.com/mcbstm32f400/) evaluation board shown in the preceding image features the STMicroelectronics STM32F407IGHx microcontroller part. The board specification includes the following:

  • STM32F407IG Microcontroller

  • On-chip and external memory

  • 2.4 inch QVGA TFT LCD and touchscreen

  • USB 2.0 Ports

  • CAN interface

  • Serial/UART Port

  • Micro SD Card Interface

  • 5-position Joystick

  • 3-axis accelerometer

  • 3-axis Gyroscope

  • ADC Potentiometer input

  • Audio Codec with Speaker and Microphone

  • Digital Microphone

  • Digital VGA Camera

  • Push Buttons and LEDs directly connected to I/O ports

  • Debug Interface

MCU manufacturers like Texas Instruments (TI), STMicroelectronics, Freescale, Atmel, Analog Devices, Silicon Labs, MikroElektronika, NXP, and Nordic Semiconductor all market evaluation boards featuring the Cortex-M4. Some of these offer cheaper, entry-level board options costing just a few dollars with functionality that can be enhanced by adding additional modules.

An insight into the range of microcontroller devices supported by MDK-ARM can be gained by scrolling through the list of packs listed by the Pack Installer. Keil markets a range of Cortex-M evaluation boards designed by themselves and other manufacturers (http://www.keil.com/boards/cortexm.asp) that feature a number of microcontrollers. Keil's range of boards features NXP, STMicroelectronics, and Freescale microcontrollers. The MCBSTM32 (Cortex-M3) and MCBSTM32F400 (Cortex-M4) evaluation boards offer one of the more expensive evaluation routes, but they are populated with a comprehensive set of I/O peripherals, including a QVGA TFT LCD touchscreen. STM (http://www.st.com) markets a similar evaluation board called the STM3241G-EVAL, offering almost identical features to Keil's but employing a slightly different PCB layout and using the STM32F417IG part.

Netduino (http://netduino.com/) offers a series of open source evaluation boards based on the STM32F405RG microcontroller featuring a Cortex-M4 core with open source software development support. Netduino is supported by an enthusiastic community of developers—a selection of projects which demonstrate the potential of the device are available.

Documentation for target devices and evaluation boards is available from the manufacturer. For example, those using the MCBSTM32F400 board will need to refer to the reference manual RM0090 (http://www.st.com), the MCBSTM32F200/400 User's Guide (http://www.keil.com), the ARM Cortex-M4 Processor Technical Reference Manual, and the Cortex-M4 Devices Generic User Guide (http://infocenter.arm.com).

You will also find that the schematic diagram of the evaluation board, at http://www.keil.com/mcbstm32f400/mcbstm32f400-schematics.pdf, is also useful for resolving ambiguities in the libraries. If you use MDK-ARM, then once a new project has been created and the target microcontroller identified, most of the relevant documentation can be accessed via the Books tab within the project window.