EMBEDDEDSYSTEMS:
REALTIMEOPERATING
SYSTEMSFORARMCORTEX-M
MICROCONTROLLERS Volume3
FourthEdition,
January2017
JonathanW.Valvano
Fourthedition
January2017
ARManduVisionareregisteredtrademarksofARMLimited.
CortexandKeilaretrademarksofARMLimited.
StellarisandTivaareregisteredtrademarksTexasInstruments.
CodeComposerStudioisatrademarkofTexasInstruments.
Allotherproductorservicenamesmentionedhereinarethetrademarksoftheir
respectiveowners.
Inordertoreducecosts,thiscollegetextbookhasbeenself-published.
Formoreinformationaboutmyclasses,myresearch,andmybooks,
see />
Forcorrectionsandcomments,pleasecontactmeat:
Pleasecitethisbookas:J.W.Valvano,
EmbeddedSystems:RealTimeOperatingSystemsfor
ARM ® Cortex -MMicrocontrollers,Volume3,
ISBN:978-1466468863.
Copyright©2017JonathanW.Valvano
Allrightsreserved.Nopartofthisworkcoveredbythecopyright
hereinmaybereproduced,transmitted,stored,orusedinanyformor
byanymeansgraphic,electronic,ormechanical,includingbutnot
limitedtophotocopying,recording,scanning,digitizing,taping,web
distribution,informationnetworks,orinformationstorageand
retrieval,exceptaspermittedunderSection107or108ofthe1976
UnitedStatesCopyrightAct,withoutthepriorwrittenpermissionof
thepublisher.
ISBN-13:978-1466468863
ISBN-10:1466468866
TableofContents
PrefacetoTheFourthEdition
PrefacetoVolume3
Acknowledgements
1.ComputerArchitecture
1.1.IntroductiontoRealTimeOperatingSystems
1.1.1.Real-timeoperatingsystems
1.1.2.EmbeddedSystems
1.2.ComputerArchitecture
1.2.1.Computers,processors,andmicrocontrollers
1.2.2.Memory
1.3.Cortex-MProcessorArchitecture
1.3.1.Registers
1.3.2.Stack
1.3.3.Operatingmodes
1.3.4.Reset
1.3.5.Clocksystem
1.4.TexasInstrumentsCortex-MMicrocontrollers
1.4.1.IntroductiontoI/O
1.4.2.TexasInstrumentsTM4C123LaunchPadI/Opins
1.4.3.TexasInstrumentsTM4C1294Connected
LaunchPadI/Opins
1.4.4.TexasInstrumentsMSP432LaunchPadI/Opins
1.4.5.InterfacingtoaLaunchPad
1.5.ARMCortex-MAssemblyLanguage
1.5.1.Syntax
1.5.2.Addressingmodesandoperands
1.5.3.Listoftwelveinstructions
1.5.4.Accessingmemory
1.5.5.Functions
1.5.6.ARMCortexMicrocontrollerSoftwareInterface
Standard
1.5.7.Conditionalexecution
1.5.8.Stackusage
1.5.9.Floating-pointmath
1.5.10.Keilassemblerdirectives
1.6.PointersinC
1.6.1.Pointers
1.6.2.Arrays
1.6.3.Linkedlists
1.7.MemoryManagement
1.7.1.Useoftheheap
1.7.2.Simplefixed-sizeheap
1.7.3.Memorymanager:mallocandfree
1.8.Introductiontodebugging
1.9.Exercises
2.MicrocontrollerInput/Output
2.1.ParallelI/O
2.1.1.TM4CI/Oprogramming
2.1.2.MSP432I/Oprogramming
2.2.Interrupts
2.2.1.NVIC
2.2.2.SysTickperiodicinterrupts
2.2.3.Periodictimerinterrupts
2.2.4.Criticalsections
2.2.5.Executingperiodictasks
2.2.6.Softwareinterrupts
2.3.FirstinFirstOut(FIFO)Queues
2.4.Edge-triggeredInterrupts
2.4.1.Edge-triggeredinterruptsontheTM4C123
2.4.2.Edge-triggeredInterruptsontheMSP432
2.5.UARTInterface
2.5.1.Transmittinginasynchronousmode
2.5.2.Receivinginasynchronousmode
2.5.3.Interrupt-drivenUARTontheTM4C123
2.5.4.Interrupt-drivenUARTontheMSP432
2.6.SynchronousTransmissionandReceivingusingtheSSI
2.7.InputCaptureorInputEdgeTimeMode
2.7.1.Basicprinciples
2.7.2.PeriodmeasurementontheTM4C123
2.7.3.PeriodmeasurementontheMSP432
2.7.4.Pulsewidthmeasurement
2.7.5.Ultrasonicdistancemeasurement
2.8.PulseWidthModulation
2.8.1.PulsewidthmodulationontheTM4C123
2.8.2.PulsewidthmodulationontheMSP432
2.9.AnalogOutput
2.10.AnalogInput
2.10.1.ADCParameters
2.10.2.InternalADConTM4C
2.10.3.InternalADConMSP432
2.10.4.IRdistancemeasurement
2.11.OSConsiderationsforI/ODevices
2.11.1BoardSupportPackage
2.11.2PathExpression
2.12.Debugging
2.12.1.FunctionalDebugging
2.12.2.PerformanceDebugging(FFTanalysis)
2.12.3.Debuggingheartbeat
2.12.4.Profiling
2.13.Exercises
3.ThreadManagement
3.1.IntroductiontoRTOS
3.1.1.Motivation
3.1.2.Parallel,distributedandconcurrentprogramming
3.1.3.Introductiontothreads
3.1.4.Statesofamainthread
3.1.5.Real-timesystems
3.1.6.Producer/Consumerproblemusingamailbox
3.1.7.Scheduler
3.2.Functionpointers
3.3.ThreadManagement
3.3.1.Twotypesofthreads
3.3.2.ThreadControlBlock(TCB)
3.3.3.Creationofthreads
3.3.4.LaunchingtheOS
3.3.5.Switchingthreads
3.3.6.ProfilingtheOS
3.3.7.LinkingassemblytoC
3.3.8.Periodictasks
3.4.Semaphores
3.5.ThreadSynchronization
3.5.1.Resourcesharing,nonreentrantcodeormutual
exclusion
3.5.2.Conditionvariable
3.5.3.Threadcommunicationbetweentwothreadsusinga
mailbox
3.6.ProcessManagement
3.7.Dynamicloadingandlinking
3.8.Exercises
4.TimeManagement
4.1.Cooperation
4.1.1.Spinlocksemaphoreimplementationwith
cooperation
4.1.2.CooperativeScheduler
4.2.Blockingsemaphores
4.2.1.Theneedforblocking
4.2.2.Theblockedstate
4.2.3.Implementation
4.2.4.Threadrendezvous
4.3.FirstInFirstOutQueue
4.3.1.Producer/ConsumerproblemusingaFIFO
4.3.2.Little’sTheorem
4.3.3.FIFOimplementation
4.3.4.Three-semaphoreFIFOimplementation
4.3.5.Two-semaphoreFIFOimplementation
4.3.6.One-semaphoreFIFOimplementation
4.3.7.KahnProcessNetworks
4.4.Threadsleeping
4.5.Deadlocks
4.6.Monitors
4.7.FixedScheduling
4.8.Exercises
5.Real-timeSystems
5.1.DataAcquisitionSystems
5.1.1.Approach
5.1.2.PerformanceMetrics
5.1.3.AudioInput/Output
5.2.Priorityscheduler
5.2.1.Implementation
5.2.2.Multi-levelFeedbackQueue
5.2.3.Starvationandaging
5.2.4.PriorityinversionandinheritanceonMars
Pathfinder
5.3.Debouncingaswitch
5.3.1.Approachtodebouncing
5.3.2.DebouncingaswitchonTM4C123
5.3.3.DebouncingaswitchonMSP432
5.4.Runningeventthreadsashighprioritymainthreads
5.5.AvailableRTOS
5.5.1.MicriumuC/OS-II
5.5.2.TexasInstrumentsRTOS
5.5.3.ARMRTXRealTimeOperatingSystem
5.5.4.FreeRTOS
5.5.5.OtherRealTimeOperatingSystems
5.6.Exercises
6.DigitalSignalProcessing
6.1.BasicPrinciples
6.2.MultipleAccessCircularQueue
6.3.UsingtheZ-TransformtoDeriveFilterResponse
6.4.IIRFilterDesignUsingthePole-ZeroPlot
6.5.DiscreteFourierTransform
6.6.FIRFilterDesign
6.7.Direct-FormImplementations.
6.8.Exercises
7.High-SpeedInterfacing
7.1.TheNeedforSpeed
7.2.High-SpeedI/OApplications
7.3.GeneralApproachestoHigh-SpeedInterfaces
7.3.1.HardwareFIFO
7.3.2.DualPortMemory
7.3.3.Bank-SwitchedMemory
7.4.FundamentalApproachtoDMA
7.4.1.DMACycles
7.4.2.DMAInitiation
7.4.3.BurstversusSingleCycleDMA
7.4.4.SingleAddressversusDualAddressDMA
7.4.5.DMAprogrammingontheTM4C123
7.6.Exercises
8.Filesystemmanagement
8.1.PerformanceMetrics
8.1.1.Usage
8.1.2.Specifications
8.1.3.Fragmentation
8.2.FileSystemAllocation
8.2.1.Contiguousallocation
8.2.2.Linkedallocation
8.2.3.Indexedallocation
8.2.4.Fileallocationtable(FAT)
8.3.SolidStateDisk
8.3.1.Flashmemory
8.3.2.Flashdevicedriver
8.3.3.eDiskdevicedriver
8.3.4.Securedigitalcardinterface
8.4.SimpleFileSystem
8.4.1.Directory
8.4.2.Allocation
8.4.3.Freespacemanagement
8.5.Write-onceFileSystem
8.5.1.Usage
8.5.2.Allocation
8.5.3.Directory
8.5.4.Append
8.5.5.Freespacemanagement
8.6.Readers-WritersProblem
8.7.Exercises
9.CommunicationSystems
9.1.Fundamentals
9.1.1.Thenetwork
9.1.2.PhysicalChannel
9.1.3.WirelessCommunication
9.1.4.Radio
9.2.ControllerAreaNetwork(CAN)
9.2.1.TheFundamentalsofCAN
9.2.2.TexasInstrumentsTM4CCAN
9.3.EmbeddedInternet
9.3.1.Abstraction
9.3.2.MessageProtocols
9.3.3.EthernetPhysicalLayer
9.3.4.EthernetontheTM4C1294
9.4.InternetofThings
9.4.1.BasicConcepts
9.4.2.UDPandTCPPackets
9.4.3.Webserver
9.4.4.UDPcommunicationoverWiFi
9.4.5.OtherCC3100Applications
9.4.BluetoothFundamentals
9.4.1.BluetoothProtocolStack
9.4.2.Client-serverParadigm
9.5.CC2650Solutions
9.5.1.CC2650Microcontroller
9.5.2.SingleChipSolution,CC2650LaunchPad
9.6.NetworkProcessorInterface(NPI)
9.6.1.Overview
9.6.2.ServicesandCharacteristics
9.6.3.Advertising
9.6.4.ReadandWriteIndications
9.7.ApplicationLayerProtocolsforEmbeddedSystems
9.7.1.CoAP
9.7.2MQTT
9.8.Exercises
10.RoboticSystems
10.1.IntroductiontoDigitalControlSystems
10.2.BinaryActuators
10.2.1.ElectricalInterface
10.2.2.DCMotorInterfacewithPWM
10.3.Sensors
10.4.Odometry
10.5.SimpleClosed-LoopControlSystems.
10.6.PIDControllers
10.6.1.GeneralApproachtoaPIDController
10.6.2.DesignProcessforaPIDController
10.7.FuzzyLogicControl
10.8.Exercises
Appendix1.Glossary
Appendix2.SolutionstoCheckpoints
ReferenceMaterial
PrefacetoTheFourthEdition
Therearetwomajoradditionstothisfourthedition.First,thisversion
supportsboththeTM4CandtheMSP432architectures.Thematerial
fortheLM3Sserieshasbeenremoved.Volumes1and2focusedon
thehardwareandsoftwareaspectsI/Ointerfacing.Inthisvolumewe
provideasetoflowleveldevicedriversallowingthisvolumetofocus
on real-time operating systems, digital signal processing, control
systems,andtheinternetofthings.ThesecondadditionisBluetooth
Low Energy (BLE), which will be implemented by interfacing a
CC2650, in a similar manner with which IEEE802.11b wifi is
implementedinthisbookusingtheCC3100.RunningontheCC2650
will be an application programmer interface called Simple Network
Processor(SNP).SNPallowstheTM4C123/MSP432microcontroller
toimplementBLEusingasimplesetofUARTmessaging.Offloading
theBLEfunctionstotheCC2650allowsthetargetmicrocontrollerto
implementsystemlevelfunctionswithouttheburdenofsatisfyingthe
real-timecommunicationrequiredbyBluetooth.
PrefacetoVolume3
Embeddedsystemsareaubiquitouscomponentofoureverydaylives.
We interact with hundreds of tiny computers every day that are
embedded into our houses, our cars, our toys, and our work. As our
world has become more complex, so have the capabilities of the
microcontrollers embedded into our devices. The ARM Cortex-M
family represents the new class of microcontrollers much more
powerfulthanthedevicesavailabletenyearsago.Thepurposeofthis
bookistopresentthedesignmethodologytotrainyoungengineersto
understandthebasicbuildingblocksthatcomprisedeviceslikeacell
phone, an MP3 player, a pacemaker, antilock brakes, and an engine
controller.
This book is the third in a series of three books that teach the
fundamentalsofembeddedsystemsasappliedtotheARMCortex-M
familyofmicrocontrollers.Thisthirdvolumeisprimarilywrittenfor
senior undergraduate or first-year graduate electrical and computer
engineeringstudents.Itcouldalsobeusedforprofessionalswishingto
designordeployareal-timeoperatingsystemontoanARMplatform.
The first book Embedded Systems: Introduction to ARM Cortex-M
Microcontrollers is an introduction to computers and interfacing
focusingonassemblylanguageandCprogramming.Thesecondbook
Embedded Systems: RealTime Interfacing to ARM Cortex-M
Microcontrollers focuses on interfacing and the design of embedded
systems. This third book is an advanced book focusing on operating
systems,high-speedinterfacing,controlsystems,androbotics.
Anembeddedsystemisasystemthatperformsaspecifictaskandhas
a computer embedded inside. A system is comprised of components
and interfaces connected together for a common purpose. This book
presents components, interfaces and methodologies for building
systems.Specifictopicsincludemicrocontrollers,design,verification,
hardware/software synchronization, interfacing devices to the
computer, timing diagrams, real-time operating systems, data
collectionandprocessing,motorcontrol,analogfilters,digitalfilters,
andreal-timesignalprocessing.
Ingeneral,theareaofembeddedsystemsisanimportantandgrowing
disciplinewithinelectricalandcomputerengineering.Inthepast,the
educational market of embedded systems has been dominated by
simplemicrocontrollerslikethePIC,the9S12,andthe8051.Thisis
because of their market share, low cost, and historical dominance.
However, as problems become more complex, so must the systems
thatsolvethem.Anumberofembeddedsystemparadigmsmustshift
inordertoaccommodatethisgrowthincomplexity.First,thenumber
of calculations per second will increase from millions/sec to
billions/sec.Similarly,thenumberoflinesofsoftwarecodewillalso
increase from thousands to millions. Thirdly, systems will involve
multiple microcontrollers supporting many simultaneous operations.
Lastly,theneedforsystemverificationwillcontinuetogrowasthese
systems are deployed into safety critical applications. These changes
aremorethanasimplegrowthinsizeandbandwidth.Thesesystems
mustemployparallelprogramming,high-speedsynchronization,realtime operating systems, fault tolerant design, priority interrupt
handling, and networking. Consequently, it will be important to
provideourstudentswiththesetypesofdesignexperiences.TheARM
platformisbothlowcostandprovidesthehighperformancefeatures
required in future embedded systems. Although the ARM market
shareislargeandwillcontinuetogrow.Furthermore,studentstrained
ontheARMwillbeequippedtodesignsystemsacrossthecomplete
spectrumfromsimpletocomplex.Thepurposeofwritingthesethree
books at this time is to bring engineering education into the 21st
century.
Thisbookemploysmanyapproachestolearning.Itwillnotincludean
exhaustive recapitulation of the information in data sheets. First, it
beginswithbasicfundamentals,whichallowsthereadertosolvenew
problems with new technology. Second, the book presents many
detailed design examples. These examples illustrate the process of
design.There aremultiplestructural componentsthat assistlearning.
Checkpoints, with answers in the back, are short easy to answer
questions providing immediate feedback while reading. Homework
problems,whichtypicallyaresimplerthanlabs,providemorelearning
opportunities. The book includes an index and a glossary so that
informationcanbesearched.Themostimportantlearningexperiences
in a class like this are of course the laboratories. More detailed lab
descriptionsareavailableontheweb.SpecificallyforVolume1,look
atthelabassignmentsforEE319K.ForVolume2refertotheEE445L
labs, and for this volume, look at the lab assignments for
EE445M/EE380L.6.
There
is
a
web
site
accompanying
this
book
Posted here are ARM
Keil™ uVision® and Texas Instruments Code Composer Studio™
projectsforeachoftheexampleprogramsinthebook.Youwillalso
finddatasheetsandExcelspreadsheetsrelevanttothematerialinthis
book.
The book will cover embedded systems for ARM ® Cortex™-M
microcontrollers with specific details on the TM4C123, TM4C1294,
andMSP432.MostofthetopicscanberunonanyTexasInstruments
Cortex M microcontroller. In these books the terms MSP432 and
TM4C will refer to any of the Texas Instruments ARM Cortex-M
based microcontrollers. Although the solutions are specific for the
MSP432andTM4C families, it will be possible to use these books
forotherARMderivatives.
Acknowledgements
IoweawonderfuldebtofgratitudetoDanielValvano.Hewroteand
testedmostofthesoftwareexamplesfoundinthesebooks.Secondly,
he
maintains
the
example
web
site,
Lastly, he meticulously
proofreadthismanuscript.
Manysharedexperiencescontributedtothedevelopmentofthisbook.
First I would like to acknowledge the many excellent teaching
assistants I have had the pleasure of working with. Some of these
hard-working, underpaid warriors include Pankaj Bishnoi, Rajeev
Sethia,AdsondaRocha,BaoHua,RajRanderi,SantoshJodh,Naresh
Bhavaraju, Ashutosh Kulkarni, Bryan Stiles, V. Krishnamurthy, Paul
Johnson, Craig Kochis, Sean Askew, George Panayi, Jeehyun Kim,
Vikram Godbole, Andres Zambrano, Ann Meyer, Hyunjin Shin,
AnandRajan,AnilKottam,Chia-lingWei,JigneshShah,IcaroSantos,
David Altman, Nachiket Kharalkar, Robin Tsang, Byung Geun Jun,
John Porterfield, Daniel Fernandez, Deepak Panwar, Jacob Egner,
Sandy Hermawan, Usman Tariq, Sterling Wei, Seil Oh, Antonius
Keddis, Lev Shuhatovich, Glen Rhodes, Geoffrey Luke, Karthik
Sankar,TimVanRuitenbeek,RaffaeleCetrulo,HarshadDesai,Justin
Capogna, Arindam Goswami, Jungho Jo, Mehmet Basoglu, Kathryn
Loeffler, Evgeni Krimer, Nachiappan Valliappan, Razik Ahmed,
Sundeep Korrapati, Song Zhang, Zahidul Haq, Matthew Halpern,
Cruz Monrreal II, Pohan Wu, Saugata Bhattacharyya, Dayo Lawal,
Abhishek Agarwal, Sparsh Singhai, Nagaraja Revanna, Mahesh
Srinivasan, Victoria Bill, Alex Hsu, Dylan Zika, Chun-Kai Chang,
Zhao Zheng, Ce Wei, Kelsey Taylor Ball, Brandon Nguyen, Turan
Vural,SchuylerChristensen,DannyVo,JustinNguyen,DanialRizvi,
Armand Behroozi, Vivian Tan, Anthony Bauer, Jun Qi Lau, Corey
Cormier, Cody Horton, Youngchun Kim, Ryan Chow, Cody Horton,
Corey Cormier, and Dylan Zika. These teaching assistants have
contributedgreatlytothecontentsofthisbookandparticularlytoits
laboratory assignments. Since 1981, I estimate I have taught
embeddedsystemstoover5000students.Mystudentshaverecharged
myenergyeachsemesterwiththeirenthusiasm,dedication,andquest
for knowledge. I have decided not to acknowledge them all
individually. However, they know I feel privileged to have had this
opportunity.
Next, I appreciate the patience and expertise of my fellow faculty
members here at the University of Texas at Austin. From a personal
perspective Dr. John Pearce provided much needed encouragement
and support throughout my career. Over the last few years, I have
enjoyed teaching embedded systems with Drs. Ramesh Yerraballi,
Mattan Erez, Andreas Gerstlauer, and William Bard. Bill has
contributed to both the excitement and substance of our laboratory
based on this book. Many of the suggestions and corrections from
Chris Shore and Drew Barbier of ARM about Volume 1 applied
equally to this volume. Austin Blackstone created and debugged the
CodeComposerStudioTMversionsoftheexampleprogramspostedon
theweb.AustinalsotaughtmehowtoruntheCC3000andCC3100
WifiexamplesontheLaunchPad.
Ramesh Yerraballi and I have created two MOOCs, which have had
over 110,000 students, and delivered to 110 countries. The new
material in this book was developed under the watchful eye of
ProfessorYerraballi.Ithasbeenanhonorandprivilegetoworkwith
suchaskilledanddedicatededucator.
Andreas Gerstlauer has taught a course based on this book multiple
times, and I have incorporated many of his ideas into this edition of
the book. Furthermore, you will find a rich set of material if you
searchwiththesekeywordsGerstlauerRTOSutexas.
Sincerely, I appreciate the valuable lessons of character and
commitment taught to me by my parents and grandparents. I recall
how hard my parents and grandparents worked to make the world a
betterplaceforthenextgeneration.Mostsignificantly,Iacknowledge
thelove,patienceandsupportofmywife,Barbara,andmychildren,
BenDanandLiz.Inparticular,Dandesignedandtestedmostofthe
MSP432andTM4Csoftwarepresentedinthisbook.
By the grace of God, I am truly the happiest man on the planet,
becauseIamsurroundedbythesefinepeople.
JonathanW.Valvano
Goodluck
1.ComputerArchitecture
Chapter1objectivesareto:
•Presentabriefreviewofcomputerarchitecture
• Overview the ARM ® Cortex ™ -M processor including
assembly language • Introduce the Texas Instruments
MSP432/TM4Cfamilyofmicrocontrollers
Theoverallobjectiveofthisbookistoteachthedesignofrealtime operating systems for embedded systems. We define a
systemasrealtimeifthereisasmallandboundeddelaybetween
thetimewhenataskshouldbecompletedandwhenitisactually
completed. We will present both fundamental principles and
practical solutions. Interfacing to the microcontroller was
presented in detail in Volume 2 and reviewed in the first two
chaptersofthisbook.Theoverlapallowsthisbooktostandalone
as a text to teach embedded real time operating systems. This
firstchapterwillreviewthearchitectureoftheTexasInstruments
MSP432/TM4C family of microcontrollers. When designing
operating systems, we need to understand the details of the
architecture. In particular, we must perform many functions in
assemblylanguage.Furthermore,managingmemorywillrequire
anintimateunderstandingofhowtheprocessoraccessesmemory
atthemostbasiclevel.
1.1.IntroductiontoRealTimeOperating
Systems
1.1.1.Real-timeoperatingsystems
Acomputersystemhasmanytypesofresourcessuchasmemory,I/O,
data, and processors. A real-time operating system (RTOS) is
software that manages these resources, guaranteeing all timing
constraintsaresatisfied.Figure1.1illustratestherelationshipbetween
hardware and software. On the left is a basic system without an
operatingsystem.Softwareiswrittenbyasinglevendorforaspecific
microcontroller. As the system becomes more complex (middle
figure),anoperatingsystemfacilitatestheintegrationofsoftwarefrom
multiplevendors.Byprovidingahardwareabstractionlayer(HAL)
an operating system simplifies porting application code from one
microcontroller to another. In order to provide additional processing
power, embedded systems of the future will require multiple
microcontrollers, processors with specialized coprocessors and/or a
microcontrollerwithmultiplecores(rightfigure).Synchronizationand
assigningtasksacrossdistributedprocessorsareimportantfactors.As
thesesystemsbecomemorecomplex,theroleoftheoperatingsystem
willbeincreasinglyimportant.
Figure1.1.Anoperatingsystemisasoftwarelayerbetweenthe
applicationsoftwareandthehardware.
TheRTOSmust manageresourceslikememory,processorand I/O.
The RTOS will guarantee strict timing constraints and provide
reliable operation. The RTOS will support synchronization and
communication between tasks. As complex systems are built the
RTOS manages the integration of components. Evolution is the
notion of a system changing to improve performance, features and
reliability. The RTOS must manage change. When designing a new
system,itisgooddesignpracticetobuildanewsystembychanging
anexistingsystem.Thenotionofportabilityistheeaseatwhichone
systemcanbechangedoradaptedtocreateanothersystem.
The response time or latency is the delay from a request to the
beginningoftheserviceofthatrequest.Therearemanydefinitionsof
bandwidth. In this book we define bandwidth as the number of
information bytes/sec that can be transferred or processed. We can
compare and contrast regular operating systems with real-time
operatingsystems.
RegularOS
Complex
Besteffort
Fairness
Averagebandwidth
Unknowncomponents
Unpredictablebehavior
Plugandplay
Real-timeOS
Simple
Guaranteedresponse
Stricttimingconstraints
Minimumandmaximum
limits
Knowncomponents
Predictablebehavior
Upgradable
Table1.1.Comparisonofregularandreal-timeoperatingsystems.
FromTable1.1weseethatreal-timeoperatingsystemshavetobesimple
so they may be predictable. While traditional operating systems gauge
their performance in terms of response time and fairness, real-time
operatingsystemstargetstricttimingconstraintsandupper,lowerbounds
onbandwidth.Onecanexpecttoknowallthecomponentsofthesystem
atdesigntimeandcomponentchangeshappenmuchmoreinfrequently.
Checkpoint1.1:Whatdoesrealtimemean?
1.1.2.EmbeddedSystems
Anembedded system is a smart device with a processor that has a
special and dedicated purpose. The user usually does not or cannot
upgradethehardware/softwareorchangewhatthesystemdoes.Real
timemeansthattheembeddedsystemmustrespondtocriticalevents
withinastrictlydefinedtime,calledthedeadline.Aguaranteetomeet
alldeadlinescanonlybemadeifthebehavioroftheoperatingsystem
can be predicted. In other words the timing must be deterministic.
Therearefivetypesofsoftwarefunctionstheprocessorcanperform
inanembeddedsystem.Similartoageneral-purposecomputer,itcan
perform mathematical and/or data processing operations. It can
analyze data and make decisions based on the data. A second type
involves handling and managing time: as an input (e.g., measure
period), an output (e.g., output waveforms), and a means to
synchronize tasks (e.g., run 1000 times a second). A third type
involves real-time input/output for the purpose of measurement or
control. The fourth type involves digital signal processing (DSP),
which are mathematical calculations on data streams. Examples
includeaudio,video,radar,andsonar.Thelasttypeiscommunication
and networking. As embedded systems become more complex, how
the components are linked together will become increasingly
important.
TherearetwoclassificationsofembeddedsystemsasshowninFigure
1.2. A transformative system collects data from inputs, makes
decisions,andaffectsitsenvironmentbydrivingactuators.Therobot
systems presented in Chapter 10 are examples of transformative
systems.Areactivesystemcollectsdatainacontinuousfashionand
produceoutputsalsoinacontinuousfashion.Digitalsignalprocessing
algorithmspresentedinChapter6areexamplesofreactivesystems.
Figure1.2.Embeddedsystemscantransformorreacttothe
environment.
Sixconstraintstypifyanembeddedsystem.First,theyaresmallsize.
For example, many systems must be handheld. Second, they must
havelowweight. If the device is deployed in a system that moves,
e.g., attached to a human, aircraft or vehicle, then weight incurs an
energycost.Third,theyoftenmustbelowpower.Forexample,they
might need to operate for a long time on battery power. Low power
alsoimpactstheamountofheattheyareallowedtogenerate.Fourth,
embedded systems often must operate in harshenvironments, such
asheat,pressure,vibrations,andshock.Theymaybesubjecttonoisy
power, RF interference, water, and chemicals. Fifth, embedded
systemsareoftenusedinsafetycriticalsystems.Real-timebehavior
is essential. For these systems they must function properly at
extremely high levels of reliability. Lastly, embedded systems are
extremely sensitive to cost. Most applications are profit-driven. For
high-volume systems a difference in pennies can significantly affect
profit.
Checkpoint1.2:Whatisanembeddedsystem?
Checkpoint1.3:Listthesixconstraintstypicallyfoundinan
embeddedsystem?