The designer's guide to the cortex-m processor family trevor martin - The ebook in PDF format with a

Page 1


https://ebookmass.com/product/the-designers-guide-to-thecortex-m-processor-family-trevor-martin/

Instant digital products (PDF, ePub, MOBI) ready for you

Download now and discover formats that fit your needs...

Definitive Guide to Arm Cortex-M23 and Cortex-M33 Processors Yiu

https://ebookmass.com/product/definitive-guide-to-arm-cortex-m23-andcortex-m33-processors-yiu/

ebookmass.com

The Definitive Guide to Gaydon era Aston Martin: The Ultimate Aston Martin Guide

https://ebookmass.com/product/the-definitive-guide-to-gaydon-eraaston-martin-the-ultimate-aston-martin-guide/

ebookmass.com

Wasps of the World: A Guide to Every Family (A Guide to Every Family, 8) Noort

https://ebookmass.com/product/wasps-of-the-world-a-guide-to-everyfamily-a-guide-to-every-family-8-noort/

ebookmass.com

eTextbook 978-0323354097 Understanding Pathophysiology 6th Edition

https://ebookmass.com/product/etextbook-978-0323354097-understandingpathophysiology-6th-edition/

ebookmass.com

Introduction to Chinese Culture 1st ed. Edition Guobin Xu

https://ebookmass.com/product/introduction-to-chinese-culture-1st-ededition-guobin-xu/

ebookmass.com

Gender and Mobility in Africa 1st ed. Edition Kalpana Hiralal

https://ebookmass.com/product/gender-and-mobility-in-africa-1st-ededition-kalpana-hiralal/

ebookmass.com

Who's Sorry Now? Maggie Robinson

https://ebookmass.com/product/whos-sorry-now-maggie-robinson/

ebookmass.com

Betting on Horse Racing For Dummies 2nd Edition Richard Eng

https://ebookmass.com/product/betting-on-horse-racing-for-dummies-2ndedition-richard-eng/

ebookmass.com

When Cities Lobby: How Local Governments Compete for Power in State Politics Julia Payson

https://ebookmass.com/product/when-cities-lobby-how-local-governmentscompete-for-power-in-state-politics-julia-payson/

ebookmass.com

Eco-design of Maritime Infrastructures Sylvain Pioch

https://ebookmass.com/product/eco-design-of-maritime-infrastructuressylvain-pioch/

ebookmass.com

TheDesigner’sGuidetothe Cortex-MProcessorFamily

Thispageintentionallyleftblank

TheDesigner’sGuidetothe Cortex-MProcessorFamily

ThirdEdition

Hitex(UK)Ltd.,Coventry,England,UnitedKingdom

NewnesisanimprintofElsevier

TheBoulevard,LangfordLane,Kidlington,OxfordOX51GB,UnitedKingdom 50HampshireStreet,5thFloor,Cambridge,MA02139,UnitedStates

Copyright©2023ElsevierLtd.Allrightsreserved.

Nopartofthispublicationmaybereproducedortransmittedinanyformorbyanymeans,electronicormechanical, includingphotocopying,recording,oranyinformationstorageandretrievalsystem,withoutpermissioninwritingfromthe publisher.Detailsonhowtoseekpermission,furtherinformationaboutthePublisher’spermissionspoliciesandour arrangementswithorganizationssuchastheCopyrightClearanceCenterandtheCopyrightLicensingAgency,canbefound atourwebsite: www.elsevier.com/permissions.

ThisbookandtheindividualcontributionscontainedinitareprotectedundercopyrightbythePublisher(otherthanasmay benotedherein).

Notices

Knowledgeandbestpracticeinthisfieldareconstantlychanging.Asnewresearchandexperiencebroadenour understanding,changesinresearchmethods,professionalpractices,ormedicaltreatmentmaybecomenecessary.

Practitionersandresearchersmustalwaysrelyontheirownexperienceandknowledgeinevaluatingandusingany information,methods,compounds,orexperimentsdescribedherein.Inusingsuchinformationormethodstheyshouldbe mindfuloftheirownsafetyandthesafetyofothers,includingpartiesforwhomtheyhaveaprofessionalresponsibility.

Tothefullestextentofthelaw,neitherthePublishernortheauthors,contributors,oreditors,assumeanyliabilityforany injuryand/ordamagetopersonsorpropertyasamatterofproductsliability,negligenceorotherwise,orfromanyuseor operationofanymethods,products,instructions,orideascontainedinthematerialherein.

ISBN:978-0-323-85494-8

ForInformationonallNewnespublications visitourwebsiteat https://www.elsevier.com/books-and-journals

Publisher: MaraE.Conner

AcquisitionsEditor: TimPitts

EditorialProjectManager: ZsereenaRoseMampusti

ProductionProjectManager: ErragountaSaibabuRao

CoverDesigner: ChristianJ.Bilbow

TypesetbyMPSLimited,Chennai,India

Exercise9.1:FloatingPointUnit

Exercise9.2:SIMDInstructions

Exercise9.3:OptimizingDSPAlgorithms

Exercise9.4:UsingtheCMSIS-DSPLibrary

Thispageintentionallyleftblank

Abouttheauthor

TrevorMartinisaseniortechnicalspecialistinHitexUK,wherehehasworkedover25 years.Trevorhasworkedwithawiderangeofmicrocontrollersandassociateddevelopment tools.SincethelaunchoftheCortex-M3processorin2004,Trevorhascontributed numerousarticlesandapplicationnotesformanyoftheleadingCortex-M-based microcontrollers.HavinganextensiveknowledgeoftheCortex-Mprocessorfamily,Trevor isalsofamiliarwithmanyofthedevelopmenttechniques,applicationsoftware,and communicationprotocolsrequiredfortoday’sembeddedapplications.

Thispageintentionallyleftblank

Foreword

Thisisthethirdeditionofabookthathasbecomeadearfriendtomanysoftware developersusingArmCortex-M-basedmicrocontrollers.Whenitwasfirstpublishedin 2013,thedominanceoftheArmarchitectureinallthingsembeddedwasnotinsightand theterm“IoT”wasnotaneverydayterm.

Sincethebeginningsinthemid-2000s,ArmCortex-M-basedmicrocontrollershaveevolved fromlow-power16-bitreplacementstohigh-performanceprocessorsrunningupto1GHz. ThelistofsupporteddevicesonArm’sdevicedatabaseiscloseto10,000entries—all applicationscanbecoveredwithaspecificMCUfromoneofArm’ssiliconpartners.But notonlythecomputingperformancewasincreased,alsomanyinterfaces,especiallyfor Internetconnectivity,havebeenaddedeventothetiniestdevice.Addingsafetyand securityfeatureswhilemaintainingthelow-powerheritageandlow-costadvantageisabig challengeforsoftwaredevelopers.

Arm’s“CommonMicrocontrollerSoftwareInterfaceStandard”orinshortCMSIShelpsto simplifysoftwarereuse,reducethelearningcurveformicrocontrollerdevelopers,speedup projectbuildanddebug,andthusreducethetimetomarketfornewapplications.Itplays animportantroleineveryCortex-Msoftwaredeveloper’sday-to-daywork.Fromits humblebeginningsin2009uptonow,itgrewfromavendor-independenthardware abstractionlayertoasetoftools,APIs,frameworks,andflows.

CMSISissupportedthroughoutArm’swideecosystem.ItisanintegralpartofmanySDKs andIDEsthatareavailabletodevelopers.Lotsofthird-partysoftwarevendors(including themajorcloudserviceproviders)delivertheirsoftwarestacksasOpen-CMSIS-Packs. Newdevelopmentflowsbuiltonthesepackshelpdeveloperstomaintaintheirsoftwareand enableCI/CDDevOpsflows.UsingArmVirtualHardware,thisenablesautomatedbuild andtestinthecloud.Thesenewflowsensurehighsoftwarequalitythroughoutthewhole developmentprocess.

Whileithasbecomeanimpressivetoolboxsoftwaredeveloperscanchoosefrom,itisnot alwayseasytounderstandwhichCMSIScomponentisusedandwhen.Thisbook’stutorialbasedapproachhelpsdeveloperstounderstandthevariouscomponentsandhowtouse themeffectively.

Trevorisanexperiencedprofessionalandhasheldhundredsofworkshopsonembedded development.Hisbookisacondensedversionofhisexpertiseandtakesyouthroughall stepsthatarerequiredtocreateembeddedapplicationssuccessfully.Beingveryhands-on, bothnewandexperienceddeveloperscanlearnnewapproachestoembeddedsoftware development.IhopeyouenjoyreadingitasmuchasIdid.

ChristopherSeidl

Preface

ARMfirstintroducedtheCortex-Mprocessorfamilyin2004.Sincethen,theCortex-M processorfamilyhasgainedwideacceptanceasgeneral-purposeprocessorsforsmall microcontrollers.Atthetimeofwriting,thereareseveralthousandsofstandard microcontrollersthatfeaturetheCortex-Mprocessorandthepaceofdevelopmentshowsno signofslowingdown.TheCortex-Mprocessorisnowwellestablishedasanindustry standardarchitectureforembeddedsystems.Assuch,theknowledgeofhowtouseitis becomingarequisiteskillforprofessionaldevelopers.Thisbookisintendedasbothan introductiontotheCortex-Mprocessorfamilyandaguidetothetechniquesusedto developanapplicationsoftwaretorunonthem.Thebookiswrittenasatutorial,andthe chaptersareintendedtobeworkedthroughinorder.Eachchaptercontainsasetof examplesthatpresentthekeyprinciplesoutlinedinthisbookusingaminimalamountof code.EachexampleisdesignedtobebuiltwiththecommunityeditionoftheKeilMDK. Theseexamplesruninasimulatorsothatyoucanusethisbookwithoutanyadditional hardware.Thatsaidtheexamplescanalsoberunonlow-costhardwaremodulesthatare widelyavailablethroughtheInternet.

Thisbookcanbedividedintotwosections.Inthisfirstsection,wewillexaminethe Cortex-Mprocessors,andthesoftwaresupportandtoolsusedtodeveloptheapplication code.

Chapter1 providesanintroductionandfeatureoverviewofeachprocessorintheCortex-M family.

Chapter2 introducesthebasicsofbuildingaCprojectforaCortex-Mprocessor.

Chapter3 providesanarchitecturaldescriptionoftheCortex-M3anditsdifferencesfrom theotherCortex-Mprocessors.

Chapter4 introducestheCMSISprogrammingstandardforCortex-Mprocessors.

Chapter5 extends Chapter3 byintroducingthemoreadvancedfeaturesoftheCortex-M architecture.

Chapter6 coverstheCortex-M7andintroducesitsnewarchitecturalfeaturesandextended memorymodel.

Chapter7 discussesonthenextgenerationofCortex-Mprocessorsintroducedbythe Armv8-Marchitectureandthenewextensionstotheexistingprogrammer’smodel.

Chapter8 providesadescriptionoftheCoreSightdebugsystemanditsreal-timefeatures.

Chapter9 discussesthemathandDSPsupportavailableontheCortex-M4andhowto designreal-timeDSPapplications.

Inthesecondhalfofthisbook,wewilllookmorecloselyathowtoconstructasoftware programforaCortex-Mprocessor.ThissectionemphasizestheuseofanRTOS-based layeredsoftwarearchitecturethatpromotessoftwaretestingandcodereuse.

Chapter10 introducestheuseofanRTOSonaCortex-Mprocessor.Thisisakey frameworkthathelpstodesignandmanagemorecomplexcodebases.

Chapter11 examinessomereal-worldtechniquesthatcanbeusedwhendevelopingan RTOS-basedproject.

Chapter12 discussesontheCMSISDriverspecification.Itstartswithinstalling,followed byvalidatingandusingastandarddriver.WewillnextlookathowaCMSISdriveris constructedandhowtoextendtherangeofdriverswithacustomdriverprofile.

Chapter13 providesanintroductiontosoftwaretestingonaCortex-Mmicrocontrollerand introducesanimportantdesigntechniquecalledTest-DrivenDevelopment(TDD).

Chapter14 looksatdesigningreusablesoftwarecomponentswithinaTDDframework.The CMSISPackspecificationisusedtocreateadevice-independentcomponentthatcanbe installedintothetoolchain.

Chapter15 definesalayeredsoftwarearchitecturebasedonthetechniqueslearnedinthe precedingchapters.

With Chapter16 (thefinalchapter),wewilllookjustoverthehorizonatnear-future developmentsinsiliconandsoftware.

Thisbookisusefulforstudents,beginners,andadvancedandexperienceddevelopersalike. However,itisassumedthatyouhaveabasicknowledgeofhowtousemicrocontrollersand thatyouarefamiliarwiththethe‘C‘programminglanguage.Inaddition,itishelpfulto havebasicknowledgeofhowtousethe μVisiondebuggerandIDE.

Acknowledgments

IwouldliketothankTimPitts,ZsereenaRoseMampusti,andSaibabuRaoErragountaof ElsevierandJosephYuiofARMalongwithChristopherSeidlandalltheteamatKeil.

Thispageintentionallyleftblank

IntroductiontotheCortex-MProcessor

Family Introduction

TheobjectiveofthisbookistoprovideyouwithafundamentalunderstandingoftheCortexMprocessorfamilyandanoverviewoftheessentialsoftwarelibraries,standards, developmenttechniques,andtoolsrequiredtodesigneffectiveandefficientapplicationcode.

BookStructure

Thisbookisarrangedasatutorialanditisbesttoworkthroughitchapterbychapter.Each chaptercontainsanumberofhands-onexamplesthatusethecommunityeditionoftheKeil MDKtoolchain.TheKeilMDKistheindustry-leadingreferencetoolchainforCortex-M microcontrollersandthecommunityeditionlicenseallowsunrestrictedusefornoncommercial projects.TheMDKdebuggeralsoprovidesasophisticatedsimulatorthatallowsyoutorunmost oftheexamplesinthisbookwithouttheneedforadditionalhardware.Intheinitialchapters,we willlookatthegeneralCortex-Mprogrammer’smodelandthefeaturesofeachCortex-M processor.Alongsidetheexplorationoftheprocessorhardware,wewillseehowtoaccessthese featuresfromourdevelopmentsoftware.Wewill alsoreviewasetofspecificationscalledthe “CommonMicrocontrollerSoftwareInterfaceStandard”,whichprovidessoftwareandtoolsthat enablesoftwaredevelopmentoverthewholerangeofCortex-Mprocessors.Inthesecondhalfof thebook,wewilllookatmoresophisticatedsoftwaredevelopmenttechniquesandtheninthelast fewchaptersbringthesetogethertocreateamodularcomponent-basedgeneral-purposesoftware architecturethatcanbeusedtodevelopawiderangeofapplications.Solet’smakeastartwith anoverviewofthecurrentrangeofCortex-Mprocessors.

ExternalURL

Throughoutthebook,therearealotofexternallinksandreferences.Forthepapercopyof thisbook,thereisapdfthatcontainsasetofclickablelinksforeachchapter.Thispdfcan bedownloadedfromtheGitHubrepositorywhichcontainsthebookexampleset(see Chapter2:DevelopingSoftwarefortheCortex-MFamily).IfanyoftheURLlinksstop working,Iwillupdatethepdfwithanalternative.

TheDesigner’sGuidetotheCortex-MProcessorFamily.

DOI: https://doi.org/10.1016/B978-0-323-85494-8.00016-4

© 2023ElsevierLtd.Allrightsreserved.

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.