Newnes is an imprint of Elsevier
30 Corporate Drive, Suite 400
Burlington, MA 01803, USA
The Boulevard, Langford Lane
Kidlington, Oxford, OX5 1GB, UK
© 2010 Elsevier Inc. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or by any means, electronic or
mechanical, including photocopying, recording, or any information storage and retrieval system, without
permission in writing from the publisher. Details on how to seek permission, further information about the
Publisher’s permissions policies and our arrangements with organizations such as the Copyright Clearance
Center and the Copyright Licensing Agency, can be found at our website: www.elsevier.com/permissions.
This book and the individual contributions contained in it are protected under copyright by the Publisher
(other than as may be noted herein).
Notices
Knowledge and best practice in this eld are constantly changing. As new research and experience broaden our
understanding, changes in research methods, professional practices, or medical treatment may become necessary.
Practitioners and researchers must always rely on their own experience and knowledge in evaluating and
using any information, methods, compounds, or experiments described herein. In using such information or
methods they should be mindful of their own safety and the safety of others, including parties for whom they
have a professional responsibility.
To the fullest extent of the law, neither the Publisher nor the authors, contributors, or editors, assume any
liability for any injury and/or damage to persons or property as a matter of products liability, negligence or
otherwise, or from any use or operation of any methods, products, instructions, or ideas contained in the
material herein.
Library of Congress Cataloging-in-Publication Data
Yiu, Joseph.
The denitive guide to the ARM Cortex-M3 / Joseph Yiu.
p. cm.
Includes bibliographical references and index.
ISBN 978-1-85617-963-8 (alk. paper)
1. Embedded computer systems. 2. Microprocessors. I. Title.
TK7895.E42Y58 2010
621.39’16—dc22
2009040437
British Library Cataloguing-in-Publication Data
A catalogue record for this book is available from the British Library.
For information on all Academic Press publications
visit our Web site at www.elsevierdirect.com
Printed in the United States
09 10 11 12 13 10 9 8 7 6 5 4 3 2 1
xvii
Foreword
Progress in the ARM microcontroller community since the publication of the first edition of this book
has been impressive, significantly exceeding our expectations and it is no exaggeration to say that it is
revolutionizing the world of Microcontroller Units (MCUs). There are many thousands of end users
of ARM-powered MCUs, making it the fastest growing MCU technology on the market. As such, the
second edition of Joseph’s book is very timely and provides a good opportunity to present updated
information on MCU technology.
As a community, progress has been made in many important areas including the number of com-
panies building Cortex™-M3 processor-based devices (now over 30), development of the Cortex
Microcontroller Software Interface Standard (CMSIS) enabling simpler code portability between
Cortex processors and silicon vendors, improved versions of development tool chains, and the release
of the Cortex-M0 processor to take ARM MCUs into even the lowest cost designs.
With such a rate of change it is certainly an exciting time to be developing embedded solutions
based on the Cortex-M3 processor!
—Richard York
Director of Product Marketing, ARM
xviii
Foreword
Microcontroller programmers, by nature, are truly resourceful beings. From a fixed design, they create
fantastic new products by using the microcontroller in a unique way. Constantly, they demand highly
efficient computing from the most frugal of system designs. The primary ingredient used to perform
this alchemy is the tool chain environment, and it is for this reason that engineers from ARM’s own tool
chain division joined forces with CPU designers to form a team that would rationalize, simplify, and
improve the ARM7TDMI processor design.
The result of this combination, the ARM Cortex™-M3, represents an exciting development to the
original ARM architecture. The device blends the best features from the 32-bit ARM architecture with
the highly successful Thumb-2 instruction set design while adding several new capabilities. Despite
these changes, the Cortex-M3 retains a simplified programmer’s model that will be easily recognizable
to all existing ARM aficionados.
—Wayne Lyons
Director of Embedded Solutions, ARM
xix
Preface
This book is for both hardware and software engineers who are interested in the ARM Cortex™-M3
processor. The Cortex-M3 Technical Reference Manual (TRM) and the ARMv7-M Architecture Appli-
cation Level Reference Manual already provide lots of information on this processor, but they are very
detailed and can be challenging for novice readers.
This book is intended to be a lighter read for programmers, embedded product designers, system-
on-chip (SoC) engineers, electronics enthusiasts, academic researchers, and others who are investigat-
ing the Cortex-M3 processor, with some experience of microcontrollers or microprocessors. The text
includes an introduction to the architecture, an instruction set summary, examples of some instruc-
tions, information on hardware features, and an overview of the processor’s advanced debug system. It
also provides application examples, including basic steps in software development for the Cortex-M3
processor using ARM tools as well as the Gnu’s Not Unix tool chain. This book is also suitable for
engineers who are migrating their software from ARM7TDMI to the Cortex-M3 processor because it
covers the differences between the two processors, and the porting of application software from the
ARM7TDMI to the Cortex-M3.
Acknowledgments
I would like to thank the following people for providing me with help, advice, and feedback to the first
or the second edition of this book:
Richard York, Andrew Frame, Reinhard Keil, Nick Sampays, Dev Banerjee, Robert Boys, Domi-
nic Pajak, Alan Tringham, Stephen Theobald, Dan Brook, David Brash, Haydn Povey, Gary Camp-
bell, Kevin McDermott, Richard Earnshaw, Shyam Sadasivan, Simon Craske, Simon Axford, Takashi
Ugajin, Wayne Lyons, Samin Ishtiaq, and Simon Smith.
I would like to thank Ian Bell and Jamie Brettle at National Instruments for their help in reviewing
the materials covering NI LabVIEW and for their support. I would also like to express my gratitude to
Carlos O’Donell, Brian Barrera, and Daniel Jacobowitz from CodeSourcery for their support and help
in reviewing the materials covering software development with the CodeSourcery tool chain. And, of
course, thanks to the staff at Elsevier for their professional work toward the publication of this book.
Finally, a special thank-you to Peter Cole and Ivan Yardley for their continuous support and advice
during this project.