ebook img

The Definitive Guide to ARM® Cortex®-M0 and Cortex-M0+ Processors, Second Edition PDF

742 Pages·2015·61.42 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview The Definitive Guide to ARM® Cortex®-M0 and Cortex-M0+ Processors, Second Edition

The Definitive Guide to ® ® ARM Cortex -M0 and Cortex-M0+ Processors Second Edition Joseph Yiu AMSTERDAM(cid:1)BOSTON(cid:1)HEIDELBERG(cid:1)LONDON NEWYORK(cid:1)OXFORD(cid:1)PARIS(cid:1)SANDIEGO SANFRANCISCO(cid:1)SINGAPORE(cid:1)SYDNEY(cid:1)TOKYO NewnesisanimprintofElsevier NewnesisanimprintofElsevier The Boulevard,LangfordLane,Kidlington,OxfordOX51GB,UK 225WymanStreet,Waltham,MA02451,USA Copyright©2015Elsevier Inc.Allrightsreserved. Nopart ofthispublicationmaybereproduced ortransmittedinanyformorbyanymeans,electronic or mechanical, includingphotocopying,recording,oranyinformationstorageand retrievalsystem,without permission inwriting fromthepublisher.Detailsonhowtoseekpermission,furtherinformationaboutthe Publisher’spermissionspolicies andourarrangementswithorganizationssuchastheCopyrightClearance Center andtheCopyrightLicensingAgency,canbefoundatourwebsite:www.elsevier.com/permissions. Thisbookandtheindividualcontributionscontainedinitare protected undercopyrightbythePublisher (otherthanasmaybenotedherein). Notices Knowledgeandbestpracticeinthisfieldareconstantlychanging.Asnewresearchandexperiencebroaden ourunderstanding,changesinresearchmethods,professionalpractices,ormedicaltreatmentmaybecome necessary. Practitionersandresearchersmustalwaysrelyontheirownexperienceandknowledgeinevaluatingandusing anyinformation,methods,compounds,orexperimentsdescribedherein.Inusingsuchinformationormethods theyshouldbemindfuloftheirownsafetyandthesafetyofothers,includingpartiesforwhomtheyhavea professionalresponsibility. Tothefullestextentofthelaw,neitherthePublishernortheauthors,contributors,oreditors,assumeany liabilityforanyinjuryand/ordamagetopersonsorpropertyasamatterofproductsliability,negligenceor otherwise,orfromanyuseoroperationofanymethods,products,instructions,orideascontainedinthe material herein. ISBN:978-0-12-803277-0 British LibraryCataloguing-in-PublicationData Acatalogue recordforthisbookisavailablefrom theBritishLibrary LibraryofCongressCataloguing-in-PublicationData Acatalogrecordforthisbookisavailablefrom theLibraryofCongress ForinformationonallNewnespublications visitourwebsite athttp://store.elsevier.com/ Publisher:ToddGreen Acquisition Editor:TimPitts Editorial ProjectManager:CharlotteKent ProductionProjectManager:JasonMitchell Designer: MarkRogers TypesetbyTNQBooksandJournals www.tnq.co.in Printed andboundintheUnitedStatesofAmerica This book is dedicated to the memory of my sister, Lucia Yiu . Adventurous, supportive, loads of fun and full of energy the whole family miss you. Foreword I started my professional career in 1982, working in a microprocessor software department, and focused for years on the 8051 as this microcontroller architecture wasdduring the 1990sdthe engine for all types of embedded applications. Over decades, I was part of a booming embedded industry that created a wide spectrum of processor architectures. During this time, the microcontroller market became extremely fragmented with numerous silicon vendors and technologies. Some years ago, every embedded application was created from scratch with no software reuse and ground-up training for engineers to cope with the project challenges. But over the years, microcontroller systems became increasingly complex and demanded even higher performance to fulfil thewishes for more features and convenient operations. Often these systems are also price sensitive and therefore increasingly microcontroller systems are designed as single-chip designs based on high performance 32-bit processors, which are dominant today. Meanwhile, cost pressure and challenging software development require standardization, while, at the same time, a diverse I/O connectivity requires a range of devices. (cid:1) (cid:1) To solve these challenges, the embedded industry has established the ARM Cortex -M processor series as the de-facto standard microcontroller architecture. These processors are licensed to more than 200 companies that produce devices ranging from standard microcontrollers to domain-specific sensors to complete radio communication systems for the Internet of Things. To support a wide range of applications ARM launched multiple processors that implement the Cortex-M architecture. At the low-end of the spectrum, the Cortex-M0 and Cortex-M0+ is available for applications that were previously dominated by 8-bit microcontrollers. It is no surprise that these processors are today widely used for low-cost devices. With the availability of even more capable microcontrollers, software development for these devices has become increasingly complex. Use of real-time operating systems is rapidly becoming an industry best practice and the use of prebuilt middleware as well as software reuse is gaining importance for productive software engineering. Combining software building blocks often poses a problem for developers, but industry standards are a great way xxi Foreword to reduce system development costs and speed up time-to-market. And the Cortex-M processor architecture along with the CMSIS software programming standard is the basis for this hardware and software standardization. Joseph’s book, The Definitive Guide to ARM(cid:1) Cortex(cid:1)-M0 and Cortex-M0+ Processors, gives you the foundation for designing and creating applications for all devices that are based on ARM Cortex-M0 or Cortex-M0+ processors. I recommend this reading for practical every embedded engineer as it gives you in-depth ground-up knowledge for your day-to-day work. Reinhard Keil Director of MCU Tools, ARM xxii Preface Embedded system technologies have changed a lot since 2011, when the first edition of this book was published. In 2012, ARM(cid:1) announced the Cortex(cid:1)-M0þ processor and, in 2014, the Cortex-M7 processor was announced. Today, the Cortex-M processor is used in many microcontrollers, as well as in a range of mixed signals and wireless communication chips. In addition to processor design, embedded software development technologies have also moved on. As the use of the ARM Cortex-M microcontrollers has become more common, this has enabled microcontroller software developers to write more sophisticated applications. At the same time, the quest for better battery life and energy efficiency continues, along with improvements in development suites. Withallthesechanges,microcontrollerusersneedtoadapttonewtechnologiesquicklyand thustheavailabilityoftechnicalliteratureisbecomingmoreandmoreimportant.This neweditionisthereforefullofnewinformationandenhancement.Inadditiontothenew informationrelatedtotheCortex-M0þprocessor,examplesofusingseveralpopular developmentsuitesarealsocovered.Forexample,thebookhasdetailedexamplesofutilizing low-powerfeaturesinmicrocontrollersandillustrationsofusingRTOSinasimpleapplication. As the Internet of Things (IoT) is getting more attention and becoming more main-stream, there are more people taking an interest in and starting to learn about embedded programming. There are also more universities and colleges that are now moving on from teaching about legacy 8-bit and 16-bit microcontrollers to starting to teach students about 32-bit embedded processors- like ARM Cortex-M processors. Therefore, many parts of this book have been rewritten and many basic examples have been included to make this even more suitable for beginners, students, hobbyists, etc. There are of course audiences who demand in-depth information such as professional embedded software developers, researchers, or even semiconductor product designers. To cater for their needs, this book also covers a wide range of technical details and advanced examples. I hope that you will find this book helpful and enjoy using Cortex-M processors in your next embedded projects. xxiii Acknowledgment Many people have assisted me during the time I have been writing this book and this includes the assistance given when I wrote the first edition. First of all, many thanks to the various readers who have provided feedback for the first edition, enabling me to improve the contents of this second edition. There are also a number of people in ARM, including Colin Jones and Edmund Player for reviewing the contents. A number of companies have also provided me with a deal of assistance, including ST Microelectronics, Freescale and IAR Systems. Of course, without the successful first edition, the second edition would not be here. I would therefore like to express my gratitude to the following people for their help in the first edition: Amit Bhojraj, Bob (Robert) Boys, David Donley, Derek Morris, Dominic Pajak, Drew Barbier, Jamie Brettle, Jeffrey S. Mueller, Jim Kemerling, Joe Yu, John Davies, Jon Marsh, Kenneth Dwyer, Milorad Cvjetkovic, Nick Sampays, Reinhard Keil, Simon Craske, William Farlow. I would also like to thank the staff from Elsevier for their professional work in getting this book published. And finally, a big thank you to all of my friends for their encouragement and for forgiving me for being slightly anti-social (I hear you ☺), while I was working on this book. xxv Terms and Abbreviations Abbreviations Definitions AAPCS ARMarchitectureprocedurecallstandard AHB Advancedhigh-performancebus ALU Arithmeticlogicunit AMBA Advancedmicrocontrollerbusarchitecture APB Advancedperipheralbus API Applicationprogramminginterface ARMARM ARMArchitectureReferenceManual BE8 Byteinvariantbigendianmode BPU Breakpointunit CMSIS Cortexmicrocontrollersoftwareinterfacestandard CMOS Complementarymetaloxidesemiconductor CPU Centralprocessingunit DAP Debugaccessport DDR Doubledatarate(memory) DS-5 DevelopmentStudio5 DWT Datawatchpointandtraceunit(unit) EABI/ABI Embeddedapplicationbinaryinterface EWARM IARembeddedworkbenchforARM EXC_RETURN Exceptionreturn FPGA Fieldprogrammablegatearray GPIO Generalpurposeinput/output GPU Graphicprocessingunit gcc GNUCcompiler HAL Hardwareabstractionlayer ICE In-circuitemulator IDE Integrateddevelopmentenvironment ISA Instructionsetarchitecture ISR Interruptserviceroutine JTAG Jointtestactiongroup(astandardoftestanddebuginterface) LR Linkregister LSB Leastsignificantbit MCU Microcontrollerunit MDK/MDK-ARM ARM(cid:1)Keil(cid:3) MicrocontrollerDevelopmentKit MSB Mostsignificantbit Continued xxvii Terms and Abbreviations dcont’d Abbreviations Definitions MTB Microtracebuffer MSP Mainstackpointer NMI Non-maskableinterrupt NVIC Nestedvectoredinterruptcontroller OS Operatingsystem PC Programcounter PCB Printedcircuitboard PSP Processstackpointer PSR/xPSR Programstatusregister RTC Real-timeclock RVDS ARMRealViewDevelopmentSuite RTOS Real-timeoperatingsystem RTX KeilReal-TimeeXecutivekernel SCS Systemcontrolspace SCB Systemcontrolblock SoC System-on-a-Chip SP Stackpointer SPI Serialperipheralinterface SWD Serialwiredebug TAP Testaccessport TRM TechnicalReferenceManual UART Universalasynchronousreceivertransmitter ULP Ultralowpower USB Universalserialbus WIC Wakeupinterruptcontroller xxviii Conventions Various typographical conventions have been used in this book, as follows: (cid:129) Normal assembly program codes: MOVR0,R1;MovedatafromRegisterR1toRegisterR0 (cid:129) Assembly code in generalized syntax; items inside “< >” must be replaced by real register names: MRS<reg>,<special_reg>; (cid:129) C program codes: for(i=0;i<3;i++){func1();} (cid:129) Pseudo code: if(a>b){. Values: 1. 4’hC, 0x123 are both hexadecimal values 2. #3 indicates item number 3 (e.g., IRQ #3 means IRQ number 3) 3. #immed_12 refers to 12-bit immediate data 4. Register bitsdTypically used to illustrate a part of a value based on bit position. For example, bit[15:12] means bit number 15 down to 12. Register access types: 1. R is Read only 2. Wis Write only 3. R/Wis Read or Write accessible 4. R/Wc is Readable and cleared by a Write access xxix

Description:
The Definitive Guide to the ARM® Cortex®-M0 and Cortex-M0+ Processors, Second Edition explains the architectures underneath ARM’s Cortex-M0 and Cortex-M0+ processors and their programming techniques. Written by ARM’s Senior Embedded Technology Manager, Joseph Yiu, the book is packed with examp
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.