0% found this document useful (0 votes)
20 views137 pages

ES Lecture Till 16 Feb

Uploaded by

Samra Khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views137 pages

ES Lecture Till 16 Feb

Uploaded by

Samra Khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 137

Embedded Systems-I (MCT-238)

Dr. Muhammad Usman

1
Today
 Course outline
 CLOs & PLOs Mapping
 Introduction to Real-Time Operating Systems & Embedded
Systems

2
Organization & Evaluation
Lect.: Mon: 08:00am – 09:00am
Thu: 08:00am – 09:00am
Evaluation: Written
 Quiz-I
 Assignment-I
 Mid Term
 Quiz-II
 Assignment-II
 Final Term (20% Mid Term Course)
3
Lab Organization & Evaluation
Lab:
 Thu: 09:00am – 12:00pm (ECD Lab)
Evaluation:
 Sessional (Lab Performance, Tasks)
 Lab Report / Viva (Understanding, Communication)
 Home Tasks/Assignments (Performance)
 Project (Performance, Societal, Resource management &
Handling, Communication)
4
CLOs and PLOs
MCT- 238 & Embedded CLOs Level PLOs Level
MCT-238L Systems-II

MCT-238:
1. Elaborate on ARM Cortex-M Architecture, I/Os, communication C2 PLO1 High
interfaces and protocols including data acquisition techniques.
2. Implementing the timers, interrupts, communication, data
acquisition techniques, CCP and Motor control systems for C3 PLO1 High
embedded applications
3. Case-studies detailing complete embedded systems design cycle,
implementation, integration and deployment C4 PLO2 High

MCT-238L
1. Design embedded systems for diverse range of applications based on I/O P2 PLO5 Medium
ports programming, Interrupts, Serial communication, data acquisition
techniques and Motor control.
2. Skillfully demonstrate a solution as individual/group in Lab sessions/Term
Project. P4 PLO6 Medium
3. To demonstrate the project handling including use of time, resources, and
skills during its execution thus exhibiting it. A4 PLO11 Medium
4. To effectively present and communicate diverse concepts and designs for
experiments and projects utilizing embedded systems. A3 PLO10 Medium

5
Cognitive

6
Psychomotor

7
8
Course Description
 This course covers the microprocessors and microcontrollers, the
core of a digital system. The architecture, assembly/C language,
system development/simulation tools for a modern (RISC/CISC)
microcontroller are introduced.
 Complete digital systems with different peripherals and data
communication are designed, simulated and implemented.
 This is a hands-on, learn-by-doing course that shows you how to
build solutions to real-world problems using embedded systems.

9
 The course uses a bottom-up approach to problem solving,
building gradually from simple interfacing of switches and
LEDs to complex concepts like display drivers, digital to
analog conversion, generation of sound, analog to digital
conversion, graphics and interrupts.

10
Details
 Introduction: Introduction to microcontrollers and embedded
processors, microcontroller’s survey-four bit, eight bit, sixteen bit, thirty
two bit microcontrollers, comparing microprocessors and microcontrollers
 Architecture: Overview of the hardware architecture, special function
registers, program counter, introduction to pic assembly programming,
delay generation and instruction pipelining and I/O port programs.
arithmetic, logic instructions and programs, bank switching, hardware
connections. FPGA boards.
 Programming: Writing firmware in assembly language, baseline
programming in C language, timer programming in assembly and C, serial
communication, line drivers, USART programming, interrupt
programming, FPGA board programming.

11
 Interfacing and ADC: LCD and keyboard interfacing, Analog-
to-Digital converters, ADC Programming and sensor interfacing,
Introduction to data acquisition systems, I2C communication
 Motor Control: Introduction to pulse width modulation, CCP
programming, H-bridge and DC motor control, servo motor and
stepper motor control

12
Suitable Microcontroller Options:
 Arduino UNO: Suitable for beginners, provides a solid platform for learning
serial communication, basic control, and interfacing.
 The TM4C or MSP432 microcontroller: developed by Texas Instruments (TI),
suitable for IoT Devices, These controllers are commonly used in Internet of
Things (IoT) applications due to integrated features like UART, SPI, and I2C,
which are essential for wireless communication.
 STM32 Nucleo: Offers more advanced features, suitable for implementing real-
time tasks and complex control systems.
 ESP32: Ideal for wireless communication experiments (Bluetooth and Wi-Fi) due
to its built-in capabilities.

13
 Raspberry Pi Pico: Good for experimenting with microPython and GPIO
control, although it's not a full-fledged microcontroller like others on the list.
 PIC Microcontrollers: Suitable for in-depth exploration of PIC microcontroller
architecture and features.
 ARM Cortex-M based microcontrollers: These are versatile and widely used
in industrial applications, offering a range of options for different levels of
complexity.

14
Opportunities
 Projects
 Practical
 Thesis

 … Future area of research

15
Books
Textbook:

 Embedded Systems: Introduction to Arm® Cortex -M


Microcontrollers by Jonathan W. Valvano, Fifth Edition (Volume 1)

 Embedded Systems with ARM Cortex-M Microcontrollers in


Assembly Language and C by Yifeng Zhu, Third Edition 2017, E-
Man Press LLC

16
Grading Policy
 Sessional 20+10 Marks
 Mid Term 30 Marks
 End Term 40 Marks
 Includes 20% of Mid-term course
Prerequisites:
 Computer Programming-I

17
Introduction

18
Embedded Systems
 smart device with a processor that has a special and dedicated
purpose.
 user usually does not or cannot upgrade the hardware/software or
change what the system does.
 Real time system  must respond to critical events within a strictly
defined time, called the deadline.
 Timing must be deterministic  guarantee to meet all deadlines if
the behavior of the operating system can be predicted.
19
Software functions
 Functions the processor can perform in an embedded system.
 Similar to a general-purpose computer, it can perform mathematical and/or
data processing operations. Can analyze data and make decisions based on the
data.
 A second type  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 real-time input/output for the purpose of measurement or
control.
 The fourth type digital signal processing (DSP), which are mathematical
calculations on data streams. Examples include audio, video, radar, and sonar.
20
 The last type is communication and networking. As embedded systems become
more complex, how the components are linked together will become increasingly
important.

21
Embedded Systems Classifications
 A transformative system collects data from inputs, makes decisions, and affects its
environment by driving actuators. The robot systems are examples of
transformative systems.
 A reactive system collects data in a continuous fashion and produce outputs also in
a continuous fashion. Digital signal processing algorithms are examples of reactive
systems.

22
Embedded Systems Constraints
 First, they are small size. For example, many systems must be handheld.
 Second, they must have low weight. If the device is deployed in a system
that moves, e.g., attached to a human, aircraft or vehicle, then weight incurs
an energy cost.
 Third, they often must be low power. For example, they might need to
operate for a long time on battery power. Low power also impacts the amount
of heat they are allowed to generate.
 Fourth, embedded systems often must operate in harsh environments,
such as heat, pressure, vibrations, and shock. They may be subject to noisy
power, RF interference, water, and chemicals..

23
 Fifth, embedded systems are often used in safety critical systems. Real-time
behavior 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

24
Binary Information Implemented with MOS transistors

 Binary Representation:
 Information on a computer is stored in binary form.
 Binary bits can exist in one of two possible states: 1 or 0.
 Positive Logic:
 Presence of voltage is associated with '1', true, asserted, or high state.
 Absence of voltage is associated with '0', false, not asserted, or low state.
 CMOS Circuit Output:
 Complementary Metal Oxide Semiconductor (CMOS) circuits are commonly used.
 Figure 1.8 depicts the output of a typical CMOS circuit.
 Left side represents the true bit output, and the right side represents the false bit output.
 Digital Circuit Output:
 Output of digital circuits consists of a p-type transistor on top of an n-type transistor.
 Each transistor in digital circuits is either on or off.
 When on, a transistor is equivalent to a short circuit between its output pins.
 When off, a transistor is equivalent to an open circuit between its output pins.
 Cortex-M Microcontrollers on TI:
 The Cortex-M microcontrollers from Texas Instruments (TI) operate with a 3.3 V supply.
 A voltage between 2 and 5 V is considered high.
 A voltage between 0 and 1.3V is considered low, as illustrated in Figure 1.9.
 Voltage Thresholds:
 High voltage: 2 to 5 V.
 Low voltage: 0 to 1.3 V.
 There is a 0.7V separation between the high and low voltage regions.
 Reliable Operation at High Speeds:
 The 0.7 V separation is designed to ensure reliable operation at very high speeds.
 This separation helps prevent issues in digital logic functioning.
 Transistor-Level Circuit Design:
 The book does not delve into the design of transistor-level digital circuits.
 It emphasizes that the focus is not on the intricate details of transistor-level circuit
design.
 Binary Representation:
 Digital data exist as binary bits.
 Binary bits are encoded using high and low voltages.
 Multistate Representation with Bits:
 To represent information with more than two states, multiple bits are used.
 A collection of 2 bits has 4 possible states (00, 01, 10, and 11).
 A collection of 3 bits has 8 possible states (000, 001, ..., 111).
 In general, a collection of n bits has 2^n states.
 Byte Representation:
 A byte consists of eight bits.
 It is formed by grouping eight binary bits into one object.
 Another term for a collection of eight bits is an "octet," derived from Latin and Greek,
meaning 8.
 Information Forms:
 Information can take various forms, including numbers, logical states, text, instructions,
sounds, or images.
 The interpretation of bits depends on how the information is organized and, more importantly,
how it is used.
 Example of Binary Representation:
 The figure shows a byte in the state representing the binary number 01100111.
 Each bit in the byte represents a binary value (0 or 1).
 The output voltage of 3.3V corresponds to true or 1, while 0V corresponds to false or
0.
Digital Information stored in Memory
 Memory in a Computer:
 Memory consists of hardware elements in a computer for storing information.
 Byte-Addressable Memory:
 Each memory cell holds one byte and has a unique, sequential address.
 Memory Operations:
 Writing to memory involves specifying an address and 8, 16, or 32 bits of data.
 During a write cycle, data flows from the processor to memory.

 Reading from memory involves specifying an address, retrieving 8, 16, or 32 bits of


data.
 During a read cycle, data flows from memory to the processor.
 Types of Memory:
 Read Only Memory (ROM) is programmed into the device and allows only read accesses.
 Random Access Memory (RAM) is used for temporary storage and supports both read and
write operations.
 Volatility of Memory:
 ROM is nonvolatile; contents persist when power is removed.
 RAM is volatile; contents are lost when power is removed.
 Memory Speed and Density:
 Reading from ROM is quick and convenient.
 Writing to ROM, especially Flash ROM, is a two-step
process taking around 1 ms per step.
 Writing to RAM is about 100,000 times faster (around 10 ns).
 ROM is denser than RAM, allowing more bits to be packed into a chip
 Microcontroller Memory Example:
 The TM4C123 microcontroller has 32,768 bytes of RAM and 262,144 bytes of ROM.
Computer Architecture
 Components of a Computer:
 A computer integrates a processor, random access memory (RAM), read-only memory
(ROM), and input/output (I/O) ports.
 Von Neumann Architecture:
 The common bus in Figure 1.26 defines the von Neumann architecture, where data and
instructions share the same memory.
 Nature of Computers:
 Computers are not intelligent but highly capable of processing instructions.
 They store and process data based on precise instructions given to them.
 Role of Software:
 Software is an ordered sequence of specific instructions stored in memory.
 It defines tasks and their timing, forming a set of instructions executed by the processor.
 Execution of Programs:
 The processor retrieves and interprets instructions stored in memory one at a time.
 Computers execute programs quickly and efficiently based on the provided instructions.
 Microprocessor Definition:
 A microprocessor is a small processor, referring to its physical size rather than computational
ability.
 Examples include Intel Xeon, AMD FX, and Sun SPARC.
 ARM Cortex-M Microcontroller:
 An ARM® Cortex -M microcontroller comprises a processor, bus, and peripherals.
 It is designed for embedded systems, often fitting in the hand, providing a compact computing
solution.
 Microcomputer Definition:
 A microcomputer is a small computer, where "small" refers to physical size (portability)
rather than computational ability.
 For example, a desktop PC is considered a microcomputer, emphasizing size over computing
power.
 Range of Devices:
 The term "microcomputer" can also be referred to a broad range of devices, from
small chips like PIC12C508 with limited memory to powerful I7-based personal
computers.
 The term's ambiguity can lead to confusion due to the wide spectrum of devices it
encompasses.
 Ports in Computing:
 A port is a physical connection between a computer and the external world.
 Ports facilitate the entry and exit of information; input ports receive information,
and output ports send information out.
 Other terms for ports include I/O ports, I/O devices, interfaces, or simply devices.
 Role of Bus:
 A bus is a collection of wires used to transmit information between modules in a
computer system.
 It serves as a communication pathway for data exchange between different components.
 Microcontroller Definition:
 A microcontroller is a very small microcomputer that integrates all the essential
components of a computer (processor, memory, I/O) onto a single chip.
 Examples include the Atmel ATtiny, Texas Instruments MSP430, and Texas Instruments
TM4C123.
 Confusion Over Terminology:
 The term "microcomputer" can be confusing as it is used to describe a wide range of
systems.
 It encompasses small microcontrollers like the 6-pin ATtiny4 to powerful personal computers
with advanced processors and large storage capacities.
 Examples of Microcontrollers:
 Atmel ATtiny, Texas Instruments MSP430, and Texas Instruments TM4C123 are cited as
examples of microcontrollers.
 Storage in RAM:
 Computers can store information in RAM by writing to it, and they can retrieve
previously stored data by reading from it.
 RAM (Random Access Memory) is volatile, meaning that if power is interrupted and
restored, the information in RAM is lost.
 Microcontroller RAM Type:
 Most microcontrollers use static RAM (SRAM), which employs six metal-oxide-semiconductor
field-effect transistors (MOS or MOSFET) for each memory bit.
 Four transistors create two cross-coupled inverters that store binary information, and the other
two are used to read and write the bit.
 Programming ROM:
 Information is programmed into ROM using more complicated techniques compared to writing
to RAM.
 From a programming viewpoint, retrieving data from ROM is identical to retrieving data from
RAM.
 Characteristics of ROM:
 ROMs are nonvolatile, meaning information is retained even if power is interrupted and restored.
 Some ROMs are factory-programmed and cannot be changed.
 Types of Programmable ROM:
 Programmable ROM (PROM) can be erased and reprogrammed by the user.
 The erase/program sequence for PROM is typically 10,000 times slower than writing
data into RAM.
 Erasable Techniques:
 Some PROMs are erased with ultraviolet light and programmed with voltages.
 Electrically erasable PROM (EEPROM) is both erased and programmed with voltages.
 Programming Method for ROM:
 Ones cannot be directly programmed into ROM.
 The typical process involves erasing the entire ROM (placing ones) and then
programming zeros as needed.
 Flash ROM:
 Flash ROM is a type of EEPROM.
 Each flash bit requires only two MOSFET transistors.
 Flash ROM can be erased in large blocks compared to individual byte erasure in regular
EEPROM.
 Microcontroller Flash ROM Usage:
 In microcontrollers like Stellaris/Tiva, instructions and constants are stored in flash ROM.
 Variables and temporary data are stored in static RAM.
 External Devices and Functionality:
 External devices attached to the microcontroller contribute to the system's functionality.
 An input port on the microcontroller allows information about the external world to be
inputted into the computer.
 The microcontroller also has an output port to send information out to the external world.
 Input/Output Ports:
 Most pins in Figure 1.27 serve as input/output ports.
 Interface Definition:
 An interface is defined as the collection of the I/O port, external electronics, physical
devices, and software.
 It allows the computer (microcontroller) to communicate with the external world.
 Input and Output Interfaces:
 An input interface, like a switch, allows the operator to toggle the switch, and the
software recognizes the switch position.
 An output interface, like an LED, enables the software to turn the light on and off, and
the operator can visually check its status.
 Variety of Inputs and Outputs:
 Inputs and outputs can exist in digital or analog forms.
 A wide range of possible inputs and outputs includes switches, LEDs, and more.
 Classification of I/O Interfaces:
 Parallel: Binary data available simultaneously on a group of lines.
 Serial: Binary data available one bit at a time on a single line.
 Analog: Data encoded as electrical voltage, current, or power.
 Time: Data encoded as a period, frequency, pulse width, or phase shift.
Flowcharts and Structured Programming
 Designing Embedded Systems:
 Embedded systems are designed with a focus on both art and science.
 Similar to writing a paper, designing begins with defining specifications and creating an
organizational plan.
 Graphical Tools:
 Three graphical tools for describing embedded system organization: flowcharts, data flow
graphs, and call graphs.
 Recommended to use all three tools for every system design.
 Flowchart Syntax Introduction:
 Programs are typically written in a linear, one-dimensional fashion.
 Flowcharts provide a two-dimensional format, aiding in visualizing conditional branching
and function calls.
 Useful in the initial design stage to define complex algorithms and in the final
documentation stage for system use or modification.
 Flowchart Elements and Shapes:
 Oval shapes represent entry and exit points, with the main entry point marking the
software start.
 Rectangles specify process blocks, with high-level flowcharts representing many
operations and low-level flowcharts defining exact operations.
 Parallelograms denote input/output operations, making it easier to identify in
embedded systems.
 Diamond shapes define branch points or conditional blocks, with labeled arrows
representing conditions for flow directions.
 Rectangles with double lines specify a call to a predefined function, subroutine, or
procedure.
 Circles are connectors, with arrows defining labels or spots in the algorithm.
 Connectors with arrows pointing into the circle represent jumps or goto commands.
 Structured Programming:
 A consistent structure is crucial in software development.
 Structured programming, a framework, involves three basic building blocks: sequence,
conditional, and while-loop.
 Structured programs are built from these blocks and simple, well-defined commands.
 I/O functions are also considered low-level building blocks.
 Guidelines in Software Development:
 Developing guidelines is crucial to avoid getting lost in the seemingly unlimited tasks in
computer tasks.
 Selecting correct tasks is fundamental to developing great products.
 Maintaining Consistency:
 Regardless of the scale (microcontroller with 1000 lines or a large computer system with
billions), maintaining consistent structure is crucial.
 Structured Programming Blocks:
 Structured programming involves combining basic building blocks into more complex
structures.
 Basic blocks include sequence, conditional, and while-loop structures.
Concurrent and Parallel Programming
 Need for Parallel Programming:
 Single-threaded execution is not sufficient for some problems.
 Parallel programming enables the computer to execute multiple threads simultaneously.
 Multi-core processors can run separate programs concurrently in each core.
 Fundamental Building Blocks:
 Fork and join are fundamental building blocks of parallel programming.
 Fork creates multiple threads that run in parallel.
 Join combines multiple simultaneous threads into one, and execution waits until all threads
above the join are complete.
 Parallel Programming Analogy:
 Analogy of inviting friends to dig a big hole illustrates fork and join operations.
 Fork changes from working alone to multiple individuals ready to perform tasks in
parallel.
 Join brings tasks to completion, returning to a single working entity.
 Parallel and Distributed Programming:
 Multiple microcontrollers running independent software characterize parallel or
distributed programming.
 Concurrent programming allows the computer to execute multiple threads but one at
a time.
 Interrupts in Concurrency:
 Interrupts are a mechanism for implementing concurrency in real-time systems.
 Hardware-triggered interrupts initiate a software action.
 Interrupt service routines (ISRs) handle background threads in an interrupt-driven system.
 Interrupt Analogy:
 Analogy of reading a book and answering a phone call illustrates interrupt-driven systems.
 Reading a book represents executing the main program in the foreground.
 Phone ringing serves as a hardware trigger, and answering the call represents executing the ISR.
 Software Activities in Multi-threaded Example:
 Figure 1.33 represents multi-threaded software activities.
 Letters (A-E) specify different software activities.
 main is executed in the foreground, where execution is sequential and predictable.
 Foreground Execution and Predictability:
 In the foreground, execution is sequential and predictable.
 Symbol < denotes hardware triggering an interrupt service routine (ISR).
 Symbol > signifies the ISR completing execution and returning to the main program.
 Interrupt-Driven Execution:
 Interrupts cause a halt in the main program, launching the ISR.
 ISR execution is predictable, occurring every 25 μs in this example.
 ISR execution is independent of foreground execution.
 Execution Sequence in Two-threaded System:
 Execution sequence might include the main program repeatedly executing the sequence BCD.
 Periodic timer triggers the execution of activity E every 25 μs.
 Interrupts may inject <E> between any two instructions of the foreground thread.
 Real-time Constraint Satisfaction:
 In a single-processor system like ARM Cortex M, interrupts must suspend foreground execution.
 Execution sequence, including injecting <E> every 25 μs, satisfies real-time constraints.
 Illustrating Parallel Programming:
 Illustration of parallel programming using the problem of finding the maximum value in a buffer (Figure 1.34).
 Parallel execution involves finding the maximum in the first half of the buffer simultaneously with the second half.
 Execution on ARM Cortex M Microcontroller:
 ARM Cortex M microcontroller cannot execute software tasks in parallel.
 Anticipation of an increase in the market share of multicore processors in the embedded field over time.
 Multicore Processors in Desktop Computers:
 State-of-the-art microprocessors in desktop computers often have two or more cores.
 Multicore processors support parallel program execution.
 Distinguishing Parallel Programming and Multithreading:
 It is crucial to distinguish parallel programming (Figure 1.34) from multithreading (Figure 1.33).
 Multithreading involves switching among multiple software tasks, executing one task at a time.
2. Introduction to Embedded Systems
Embedded Systems
 Term "embedded microcomputer system" is explained. Here's a breakdown:
 Embedded:
 Hidden inside so that it can't be seen.
 Micro:
 Small in size.
 Computer:
 Contains a processor, memory, and a means to exchange data with the external world.
 System:
 Multiple components interfaced together for a common purpose.
 Systems have structure, behavior, and interconnectivity operating in a framework bound by
rules and regulations.
 Another term for embedded systems is Cyber-Physical Systems (introduced in 2006), as
they combine computer intelligence with physical objects in the world.
 Embedded Microcomputer System:
 Refers to a device that contains one or more microcomputers inside.
 Microcontrollers (microcomputers with processor, RAM, ROM, and I/O ports in a
single package) are often used in embedded systems due to their low cost, small size,
and low power requirements.
 Microcontrollers like the Texas Instruments TM4C family come with a variety of I/O
devices, such as parallel ports, serial ports, timers, DAC, and ADC.
 I/O devices are crucial for providing necessary functionality in an embedded system.
 Software, I/O ports, and associated interface circuits give an embedded computer
system its distinctive characteristics.
 Managing time is critical, both as an input and an output.
 Communication between microcontrollers is often required.
 Interaction with humans is referred to as the human-computer interface (HCI) or man-
machine interface (MMI).
Digital Multimeter as Embedded System
 A digital multimeter is a typical embedded system:
 Inputs:
 Mode selection dial on the front.
 Red/black test probes.
 Output:
 Liquid Crystal Display (LCD) showing measured parameters.
 Microcontroller:
 The large black chip inside the box represents the microcontroller.
 The microcontroller is the central processing unit that performs specific functions.
 Its purpose is defined by the software programmed into its Read-Only Memory
(ROM).
 The software is tailored to the specific functionality of the digital multimeter.
 Components:
 Other components inside the box include a fuse, a rotary dial for mode selection, a few
interfacing resistors, and a battery.
 Functionality:
 The digital multimeter is designed for measuring various parameters, and its functionality is
precisely defined by the embedded software.
 The mode selection dial allows users to choose the desired measurement mode.
 The red/black test probes are used for making electrical connections to the circuit being
measured.
 Two main approaches to developing embedded systems:
 Microcontroller-Based Approach:
 Microcontroller Used: ARM Cortex M-series.
 Operating System: Typically, there is no operating system.
 Software Development: The entire software system is developed for the microcontroller.
 Characteristics: These systems are characterized by low-cost and low-performance.
 Volume 3: Refers to future content that will describe how to design a real-time operating
system for the Cortex M family of microcontrollers.
 High-Performance Embedded System Approach:
 Microcontroller Used: ARM Cortex A-series (more powerful than M-series).
 Operating System: These systems typically employ an operating system.
 Development Process:
 Development Platform: Initially designed on a development platform.
 Migration: Software and hardware are migrated to a stand-alone embedded platform.
 Characteristics: These systems are designed for high performance.
Lecture 5
Interface
 Interface Definition:
 Hardware and software combined to enable communication between the computer
(microcontroller) and external hardware.
 External Device Interaction:
 External devices attached to the microcontroller facilitate interaction with the system's
environment.
 Input/Output (I/O) Interfaces Classification:
 Parallel
 Serial
 Analog
 Time
 Volume 1 (CurrentVolume) Focus:
 Introduction to microcomputer programming.
 Hardware interfacing.
 Design of embedded systems.
 Volume 2 Focus:
 Details of hardware interfacing.
 Further exploration of system design.
 Volume 3 Focus:
 Real-time operating systems.
 Application of embedded system design to:
 Real-time data acquisition.
 Digital signal processing.
 High-speed networks.
 Digital control systems.
 Device Driver:
 Set of software functions facilitating the use of an Input/Output (I/O) port.
 I/O Port Example:
 Parallel Port (General Purpose Input/Output - GPIO):
 Texas Instruments TM4C family features parallel ports, e.g., Port A.

 Port A (GPIO_PORTA_DATA_R):
 Collection of pins (usually 8).
 Configurable for input or output.
 If Input:
 Reading from GPIO_PORTA_DATA_R provides 8 bits representing digital levels (high or low).
 If Output:
 Writing to GPIO_PORTA_DATA_R sets the outputs on the eight pins to high (1) or low (0) based
on the written data value.
Applications Involving Embedded Systems
 Embedded Computer System Definition:
 A microcomputer integrated with mechanical, chemical, and electrical devices.
 Programmed for a specific dedicated purpose.
 Packaged as a complete system.
 Application Scope:
 Any electrical, mechanical, or chemical system with inputs, decisions, calculations,
analyses, and outputs is a candidate for implementation as an embedded system.
 Functional Components:
 Sensors:
 Collect information (electrical, mechanical, chemical).
 tachometer is a sensor that measures the revolutions per second of a rotating shaft.
 Electronic Interfaces: (Signal Conditioning, e.g. ADC)
 Convert sensor signals into a form acceptable for the microcomputer.
 Microcomputer Software: (Decision Making)
 Performs decisions, calculations, and analyses.
 Additional Interface Electronics: (DAC)
 Convert microcomputer outputs into the necessary form.
 Actuators:
 Create mechanical or chemical outputs.
 Example: Electrical motor converts electrical power into mechanical power.
 General-Purpose Computer System Characteristics:
 Typically equipped with a keyboard, disk, and graphics display.
 Programmable for a wide variety of purposes.
 Common applications include word processing, electronic mail, business
accounting, scientific computing, and database systems.
 User Access and Control:
 Users have access to and control over the software that governs the system.
 Users can choose the operating system and applications to run.
 Removable disk or network interface facilitates easy addition of new programs.
Common Types and Cost Range:
 Personal Computer (PC):
 Example: Apple MacBook.
 Cost: Less than $3,000.
 Workstations:
 Cost: Ranges from $3,000 to $50,000.
 Supercomputers:
 Cost: Above $50,000.
 Often employ multiple processors and have extensive memory.
 Usage Scenarios:
 Workstations and supercomputers are employed for handling large amounts of information
(business applications) or performing extensive calculations (scientific research).
 Book Focus:
 The book will primarily cover embedded computers, and while the principles apply
broadly, it won't specifically address general-purpose computers.
Impact of Embedded Microcomputers in Daily Life:
 Consumer Electronics:
 Examples: Smartphones, TVs, Audio Systems.
 Integration of microcontrollers enhances functionality and interactivity.
 Home:
 Automation and control systems.
 Home appliances with embedded microcontrollers for improved performance.
 Communications:
 Cell phones and communication devices.
 Networking equipment and infrastructure.
 Automotive:
 Modern vehicles employ numerous microcontrollers for various functions.
 Engine control, safety systems, entertainment, and navigation.
 Military:
 Defense systems and equipment.
 Embedded microcomputers play a critical role in military applications.
 Industrial:
 Manufacturing processes and control systems.
 Industrial automation and robotics.
 Business:
 Embedded systems support various business operations.
 Point-of-sale terminals, inventory management, and data processing.
 Shipping:
 Embedded systems used in logistics and tracking.
 Control systems for shipping and transportation.
 Medical:
 Medical devices and equipment.
 Patient monitoring, diagnostic tools, and treatment systems.
 Computer Components:
 Embedded microcontrollers in computer hardware.
 Enhancing functionality and performance of computer systems.
Product Life Cycle
Analyze Phase
 Specifications:
 Definition: Specifications are detailed and quantifiable descriptions of how the
system should meet its requirements. They are more technical and precise.
 Process: Converting general requirements into specific metrics or features.
 Example: For a motor controller, specifying the exact range of operating
temperatures or the precise response time in milliseconds.
 Constraints:
 Definition: Constraints are the limitations or boundaries within which the system
must be developed and operated.
 Types: These can include budgetary limits, safety standards, compatibility
requirements, component availability, and timeline constraints.
 Example: The motor controller must be developed within a set budget, adhere to safety
standards, and be compatible with existing systems.
Measures which are often considered during the analysis phase of aproject:
High–level design phase
 Modular Design: (Block Diagram)
 Definition: Dividing the system into distinct modules or subcomponents, each with
a specific functionality.
 Benefit: Enhances understandability, simplifies development, and aids in maintenance.
 Data Flow Graphs:
 Use in High-Level Design: Data flow graphs are instrumental in visualizing how
information moves through the system.
 Elements: Arrows (indicating the flow of information), rectangles (representing
hardware components), and ovals (denoting software modules).
 Advantage: They provide a clear, simplified view of the system’s operation without
getting bogged down in intricate details.
Engineering Design
 Top-Down Hierarchical Structure:
 Process: Refining and finalizing the hierarchical structure of the system.
 Mock-Ups: Creating prototypes of mechanical parts (like connectors, chassis, cables) and user
software interfaces using tools like 3-D CAD systems for realistic visualization.
 Detailed Hardware Design: Involves creating detailed mechanical drawings and ensuring there
are backup suppliers (second sources) for critical components.
 Call Graphs:
 Definition: Graphical representations showing how software and hardware modules interact.
 High-Level vs. Detailed Call Graphs: High-level call graphs depict major modules, while
detailed ones include each software function and I/O port.
 Example: In your position measurement system, the call graph would illustrate how the timer
hardware interacts with the ADC software and the LCD interface.
 Data Structure:
 Organization of information and mechanisms to access the data
 Integration of I/O Ports:
 Organization: Grouping and integrating I/O ports effectively within the system.
 Representation in Call Graph: I/O ports are typically placed at the bottom of the
call graph for clarity.
Implementation Phase
 Also called development stage because we will develop a possible solution.
 Top-Down Design and Parallel Development:
 Advantage: Allows for the simultaneous development of subcomponents, enhancing efficiency and
speed in the development process.
 Approach: Different teams or individuals can work on various aspects of the project concurrently,
provided they follow the agreed-upon design specifications and interfaces.
 Use of Simulation in Early Stages:
 Benefits: Simulations offer a faster, more flexible, and often more cost-effective method for initial
implementation compared to building physical prototypes.
 Rapid Prototyping: Facilitates quick iterations through the analysis-design-implementation-
testing-deployment cycle, leading to more refined and sophisticated products.
Testing
 First, debug the system and validate basic functions.
 Next,use careful measurements to optimize performance such as
 static efficiency (memory requirements),
 dynamic efficiency (execution speed),
 accuracy (difference between expected truth and measured),
 and stability (consistent operation.)
Maintenance
 Maintenance is the process of correcting mistakes, adding new features,
optimizing for execution speed or program size, porting to new computers or
operating systems, and reconfiguring the system to solve a similar problem.
 No system is static. Customers may change or add requirements or constraints.
 To be profitable, we probably will wish to tailor each system to the individual
needs of each customer.
 Maintenance is not really a separate phase, but rather involves additional loops
around the life cycle.
Successive Refinement
 Successive refinement, stepwise refinement, and systematic decomposition are three
equivalent terms for a technique to convert a problem statement into a software algorithm.
Example 2.1. Build a digital door lock using
seven switches.
Quality Design
 Quantitative criteria include dynamic efficiency (speed of execution), static
efficiency (memory requirements), and accuracy of the results.
 Qualitative criteria center on ease of software maintenance.
 Another qualitative way to evaluate software is ease of understanding.
 If your software is easy to understand, then it will be:
 Easy to debug (fix mistakes)
 Easy to verify (prove correctness)
 Easy to maintain (add features)
 Quantitative Performance Measurements:
 Dynamic efficiency is a measure of how fast the program executes. It is measured in seconds
or processor bus cycles.
 Static efficiency is the number of memory bytes required. Since most embedded computer
systems have both RAM and ROM, we specify memory requirement in global variables, stack
space, fixed constants and program
 Qualitative Performance Measurements:
 self-documented code,
 abstraction, modularity, and layered software.
 These issues indeed play a profound effect on the bottom-line financial success of our projects.
 Attitude
 Good engineers employ well-defined design processes when developing complex systems.
 When we work within a structured framework, it is easier to prove our system works
(verification) and to modify our system in the future (maintenance.)
Debugging theory
 Every programmer is faced with the need to debug and verify the correctness of his
or her software.
 A debugging instrument is hardware or software used for the purpose of debugging.
 Hardware-level probes like the logic analyzer, oscilloscope, and Joint Test Action Group
(JTAG standardized as the IEEE 1149.1);
 software-level tools like simulators, monitors, and profilers; and
 manual tools like inspection and print statements
 Black-box testing is simply observing the inputs and outputs without looking
inside. Black-box testing has an important place in debugging a module for its
functionality.
 On the other hand, whitebox testing allows you to control and observe the internal
workings of a system. A common mistake made by new engineers is to just
perform black box testing. Effective debugging uses both. One must always start
with black-box testing by subjecting a hardware or software module to appropriate
testcases.
 Once we document the failed test-cases, we can use them to aid us in effectively
performing the task of white-box testing.
2.7. Switch and LED Interfaces
 Switch Interface:
 Switch Types:
 Single Pole Single Throw (SPST): Has two connections.
 Normally Open (NO): Resistance is infinite when not pressed, and zero when pressed.
 Positive Logic Interface:
 Asserted State: Larger voltage when pressed (3.3V).
 Connection: One side of the switch connected to +3.3V.
 Pull-Down Resistor: Added to ground the signal when not pressed.
 Pull-Down Resistor Value: Typically 10 kΩ.
 Negative Logic Interface:
 Asserted State: Smaller voltage when not pressed (3.3V).
 Connection: One side of the switch connected to 0V.
 Pull-Up Resistor: Added to +3.3V to achieve desired logic levels.
 Pull-Up Resistor Value: Typically, 10 kΩ.
 Dealing with Switch Bounce:
 Issue: Mechanical switches can bounce.
 Solution: Software design to wait at least 10 ms between reading switch values.
2. LED Interface:
 LED Polarity:
 Anode: Labeled as a or + (longer lead).
 Cathode: Labeled as k or - (shorter lead).
 Brightness Control:
 Brightness depends on electrical power (P=IV).*
 LED Voltage: Approximately constant in the active region.
 Brightness Control: Achieved by setting the current.
 Current Limiting Resistor:
 Purpose: Limits the current through the LED.
 Calculation: Use Ohm's Law (R=V/I) based on the desired current.
 Typical Value: Often chosen to be around 330 Ω.
 Current Limiting:
 If LED current > 8 mA, direct connection may damage the microcontroller.
 Use current limiting resistor to control LED current.
 Interface Circuits:
 Two possible circuits shown in Figure 2.9.
 Circuit Operation:
 Software Output High: LED ON (Italics indicate LED ON in Figure 2.9).
 Software Output Low: LED OFF (Italics indicate LED OFF in Figure 2.9).
 Circuit Details (Using 7405/PN2222):
 Logic 1: Input to 7405/PN2222 becomes high, output becomes low, 10 mA through
LED (LED ON).
 Logic 0: Input to 7405/PN2222 becomes low, output floats, no current through LED
(LED OFF).
 ResistorValue:
 Selected to establish proper LED current.
 Active LED Voltage: ~2 V.
 Power Delivered Controlled by Current.
 When the LED current is less than 8 mA,
 we can interface it directly to an output pin without using a driver.
 The LED shown in Figure 2.10 has an operating point of 1.7 V and 1 mA.
Introduction to C
 From book vol 1 page 95
 Macro Definition:
 Macro Creation:
 Macro created using #define to define constants.
 Example: #define SIZE 10

 Macro Purpose:
 Wherever SIZE is found as a token, it is replaced with the number 10.
 Header File Inclusion:
 Directive:
 #include directive used for including another entire file at the specified position in the
program.
 Example:
 #include "tm4c123ge6pm.h"
 File Content:
 The included file (tm4c123ge6pm.h) defines all the I/O port names for the TM4C123
microcontroller.
 Usage:
 Provides access to pre-defined I/O port names and configurations for the specified
microcontroller.
Introduction to the ARM ® Cortex -M Processor
Computer Architecture
 Computer:
 Central processing unit (CPU), random access memory (RAM), read only memory
(ROM), and input/output (I/O) ports
 Common bus in Figure 1.3 defines the von Neumann architecture.

106
 Software
 An ordered sequence of very specific instructions that are stored in memory (ROM),
defining exactly what and when certain tasks are to be performed
 CPU/Processor:
 executes the software by retrieving (from memory) and interpreting these instructions
one at a time. .

107
Introduction to the ARM ® Cortex -M
Processor
 Cortex -M Architecture
 An ARM Cortex-M microcontroller includes a processor, memory and input/output
via multiple buses
 Instructions are fetched via the ICode bus and data are fetched via the System bus,
classified as a Harvard architecture.
 Having multiple busses allows the system to do several things simultaneously.
 For example, the processor could be reading an instruction from ROM using the
ICode bus and writing data to RAM using the System bus.
 Figure 1.6 shows a simplified block diagram of a microcontroller based on the
ARM Cortex-M processor.
 It is a Harvard architecture because it has separate data and instruction buses.

 Instructions are fetched from flash ROM using the ICode bus.
 Data are exchanged with memory and I/O via the system bus interface.
 There are many sophisticated debugging features utilizing the DCode bus.

109
 Having multiple buses means the processor can perform multiple tasks in parallel.
 On the TM4C123, general purpose input/output (GPIO) ports can be accessed
using either the PPB or AHPB.
 The following is some of the tasks that can occur in parallel
 ICode bus  Fetch opcode from ROM
 DCode bus  Read constant data from ROM
 System bus  Read/write data from RAM or I/O, fetch opcode from RAM
 PPB Read/write  data from internal peripherals like the NVIC
 AHPB Read/write  data from internal peripherals like the USB

110
Registers
 Registers are high-speed storage inside the processor.
 The registers are depicted in Figure 3.2.
 R0 to R12 are general purpose registers and contain either data or addresses.
 Register R13 (also called the stack pointer, SP) points to the top element of the stack.
 Register R14 (also called the link register, LR) is used to store the return location for
functions. The LR is also used in a special way during exceptions, such as interrupts.
Interrupts are covered in Chapter 9.
 Register R15 (also called the program counter, PC) points to the next instruction to be
fetched from memory.
 The processor fetches an instruction using the PC and then increments the PC.
Processor Registers
ARM Architecture Procedure Call Standard
 AAPCS, part of the ARM (ABI) Application Binary Interface
 AAPCS Register Usage:
 R0, R1, R2, R3: Used for passing input parameters to a C function.
 R4–R11: Must be preserved by functions (callee-saved registers).
 Return parameter: Placed in Register R0.
 Stack Alignment in AAPCS:
 Push and pop an even number of registers.
 Maintain an 8-byte alignment on the stack.
 Main Stack Pointer (MSP) is used, not the Process Stack Pointer (PSP).
 Three Status Registers in ARM Architecture:
 Combined as the Program Status Register (PSR).
 APSR (Application Program Status Register)
 IPSR (Interrupt Program Status Register)
 EPSR (Execution Program Status Register)

 Status Register Bits:


 N bit: Set if result is negative after an operation.
 Z bit: Set if result is zero.
 C bit: Indicates unsigned overflow (carry).
 V bit: Indicates signed overflow.
 Q bit: Indicates saturation (special arithmetic condition)
Program status register
Bits explained
 T bit in Cortex-M Processors:
 Always set to 1.
 Indicates execution of Thumb instructions (16-bit and memory efficient).
 ISR_NUMBER:
 Specifies the interrupt being handled by the processor.
 PRIMASK Register:
 Bit 0 is the interrupt mask bit.
 1: Most interrupts and exceptions are blocked.
 0: Interrupts are allowed.
 FAULTMASK Register:
 Bit 0 is the fault mask bit.
 1: All interrupts and faults are blocked.
 0: Interrupts and faults are allowed.
 Non-maskable interrupt (NMI) is unaffected by this bit.
 BASEPRI Register:
 Defines executing software's priority.
 Blocks interrupts of lower or equal priority.
 Allows higher priority interrupts.
 Example: If BASEPRI is 3, interrupts at levels 0, 1, and 2 can occur, but level 3 and
above are postponed.
 Lower numeric value indicates higher priority.
 Interrupt Processing Details:
 Further details to be covered in subsequent chapters.
Reset
 Reset Trigger:
 Occurs after power is applied.
 Can be manually triggered by a reset button on most boards.
 Processor State After Reset:
 Enters thread mode.
 Runs at a privileged level.
 Uses the Main Stack Pointer (MSP).
 Stack Pointer (SP) Initialization:
 32-bit value from flash ROM location 0 is loaded into SP.
 All stack accesses are word aligned; least significant two bits of SP must be 0.
 Program Counter (PC) Initialization:
 32-bit value from flash ROM location 4 is loaded into PC (reset vector).
 Instructions are halfword aligned; least significant bit of PC must be 0.
 Assembler or linker sets least significant bit in the reset vector to initialize the Thumb
bit (T) in the PSR.
 Thumb Bit (T) in Program Status Register (PSR):
 On ARM Cortex-M processor, should always be set to 1 after reset.
 Link Register (LR) Initialization:
 Initialized to 0xFFFFFFFF on reset.
Memory
 LM3S and TM4C microcontrollers feature Cortex-M processors.
 The family includes hundreds of members, differing mainly in memory size and
I/O modules.
 Memory maps across Cortex-M microcontrollers share a common structure:
 Flash ROM starts at 0x0000.0000.
 RAM starts at 0x2000.0000.
 Peripheral I/O space ranges from 0x4000.0000 to 0x5FFFF.FFFF.
 Private Peripheral Bus (PPB) space spans 0xE000.0000 to 0xE00F.FFFF.
Memory Maps
Little-Endian & Big-Endian
 Differences within the LM3S/TM4C family are primarily in the ending addresses
of flash and RAM.
 Cortex-M microcontrollers use a little-endian format for data storage, whereas
some ARM processors can operate in both big and little-endian modes. However,
instruction fetches are always in little endian.
 Multiple buses in the Cortex-M4, such as ICode, DCode, System bus, PPB, and
AHB, allow for parallel processing tasks, enhancing performance.
 The endianess concept, originating from Jonathan Swift’s "Gulliver’s Travels", is
used metaphorically to describe the order in which bytes are arranged in memory.
Cont…
 16-bit number storage (e.g., 1000 or 0x03E8):
 Little Endian: Stores as E8 03; E8 at address 0x2000.0850 and 03 at 0x2000.0851.
 Big Endian: Stores as 03 E8; 03 at address 0x2000.0850 and E8 at 0x2000.0851.
 32-bit number storage (e.g., 0x12345678):
 Little Endian (Cortex M): Stores as 78 56 34 12; starting with 78 at the lowest address
(0x2000.0850) to 12 at the highest (0x2000.0853).
 Big Endian: Stores as 12 34 56 78; 12 at the lowest address (0x2000.0850) to 78 at the
highest (0x2000.0853).
 Endianess in Cortex-M microcontrollers:
 Cortex-M microcontrollers utilize the little endian format for data storage.
 Character Data Storage:
 Example: Storing 'LM3S' (0x4C4D3353) in memory.
 Locations: From 0x2000.0850 to 0x2000.0853.
 Storage Order:
 Both Endianess: 'L' (0x4C) at 0x2000.0850, 'M' (0x4D) at 0x2000.0851, '3' (0x33) at
0x2000.0852, 'S' (0x53) at 0x2000.0853.
 Key Observations:
 Independence from Endianess: Character sequence storage is the same in both big and
little endian systems.
 Sequential Storage: Characters are stored and accessed in their sequential order,
irrespective of the system's endianess.
Operating Modes
 Processor Modes:
 Foreground: Known as Thread Mode, used for the main program.
 Background: Known as Handler Mode, used for interrupt service routines (ISRs).
 Mode Switching:
 Automatic between Thread and Handler Modes.
 Initiated by interrupts or system calls.
 Identification:
 Thread Mode: Indicated by ISR_NUMBER = 0.
 Handler Mode: ISR_NUMBER is set to the interrupt number being serviced.
 Stack Pointer Use:
 MSP (Main Stack Pointer): Used by all ISRs.
 Simplification: All software examples use MSP for consistency.
The Software Development Process
 Development Approach:
 Start with assembly language, then introduce C programming.
 Supported IDEs:
 ARM Keil uVision®
 Texas Instruments Code Composer Studio (CCStudio)
 IDE Features:
 Editor: For writing and editing code.
 Assembler: Converts assembly language to machine code.
 Compiler: Converts C code to machine code.
 Simulator: Tests the code in a simulated environment.
 Debugging and Deployment:
 Both IDEs support downloading and debugging code on actual Cortex M microcontrollers.
 Integrated Development Process:
 The development process, from writing code to debugging on hardware, is streamlined within each IDE.
 Software Development Process:
 Source Code Creation: Using an editor to write human-readable commands.
 Compilation/Assembly: Translating source code into object code or machine
instructions. In ARM Keil uVision®, this is done with "Project->Build Target"
(shortcut F7).
 Code Translation:
 Assembly language is typically a one-to-one translation (one line of assembly to one
machine instruction).
 High-level languages like C or Java may compile one line of code into several machine
instructions.
 Listing File: A byproduct that maps source code lines to their corresponding machine
code addresses and instructions.
 Simulation vs. Real Hardware Deployment:
 Simulator Target: Used for initial testing without needing actual hardware.
 Real Microcontroller Target: For final testing and deployment, using JTAG debugger for
downloading and debugging.
 JTAG Debugger: Serves as both a program loader and debugger, connecting via USB to
program the EEPROM of the microcontroller.
 EEPROM Programming: Done with "Flash->Download" command in uVision® IDE,
followed by system start or debugging.
 General Purpose Computers vs. Embedded Systems:
 General purpose computers load programs into volatile RAM from storage media, requiring
reload upon each restart.
 Embedded systems often store programs in non-volatile memory like EEPROM, making them
persistent across reboots.
 Learning and Development Strategy:
 Start by running existing projects.
 Modify a similar project in small steps towards your goal, verifying functionality after each
change to avoid overwhelming debugging tasks.
 Complexity in Software Development:
 Beyond sequential execution, software complexity arises from the need to make
decisions (using branches), execute subtasks (functions), and manage concurrency (via
interrupts and distributed systems).
 Handling Complexities:
 Special instructions and constructs are used to deviate from sequential execution,
including handling interrupts (for hardware events) and managing errors like bus faults
(often due to software bugs).
 These exceptions, as numbered in Figure 3.9, include
 1) The computer uses the reset vector to decide where to start (reset or power on).
 2) There can be an unconditional branch causing the software to always go to a spot.
 3) A conditional branch will go to a spot if a certain condition is true.
 4) A function call will cause the software to go execute the code for that function.
 5) A return from function will return to the place that called the function.
 6) An interrupt will suspend execution and begin an interrupt service routine.
 7) A return from interrupt will return to the place where it was before the interrupt.
 8) A hardware or software mistake will cause a bus fault and stop execution.
ARM Cortex-M Assembly Language
 There are many ARM ® processors, and this book focuses on Cortex-M
microcontrollers, which executes Thumb ® instructions extended with Thumb-2
technology.
 Focus on a subset of Thumb® instructions.
 Subset is functionally complete.
 Emphasis not on minimizing code size or optimizing execution speed.
 General forms of instructions are shown.
 Specific restrictions exist on register usage and constant sizes.
ARM & Thumb State
ARM State:
 In ARM state, the processor executes instructions from the ARM instruction set.
ARM instructions are typically 32 bits long and offer a wide range of
powerful operations.
 ARM state provides a rich set of instructions suitable for complex tasks
and high-performance computing.
 ARM instructions are generally more memory-intensive due to their longer
length.

134
Thumb State:
 In Thumb state, the processor executes a more compact instruction set
called the Thumb instruction set. Thumb instructions are 16 bits long,
which makes them more memory-efficient.
 Thumb state is designed for situations where memory bandwidth or
storage is constrained, making it suitable for applications with limited
resources.
 Thumb instructions are generally simpler than ARM instructions.

135
ARM Cortex-M Assembly Language
 Cortex-M microcontrollers executes Thumb instructions
extended with Thumb-2 technology
Syntax:
 Instructions have four fields separated by spaces
 Labels opcodes or ops operands Comments
 Labels: The label field is optional and starts in the first column
 Opcodes or pseudo-ops: The opcode field specifies which
processor command to execute.
 LDR STR MOV PUSH POP B BL BXADD SUB CPSID and
CPSIE .
 Opcodes that uses to control features of the assembly process
AREA EQU IMPORT EXPORT and ALIGN
 Operands: specifies where to find the data to execute the
136
instruction.  0, 1, 2, 3, or more operands
 Comments: optional and is ignored by the assembler, making it easier to
understand.
 a semicolon must separate the operand and comment fields.

137

You might also like