Chapter - 2
Chapter - 2
Chapter - 2
Embedded system architecture
Hardware Architecture for Embedded systems
• The central processing unit does the necessary computation based on the
input it receives from various external devices.
• The processor has limited internal memory and if this internal memory is
not sufficient for a given application external memory devices are used.
• The hardware also includes any components that facilitates the user-
application interaction such as display units, keypads etc.
2
Processor in ES
3
Micro-controller
4
…
5
Microprocessor
6
…
7
…
8
Types of Microprocessors
9
…
10
…
11
Processor Architectures
12
Von Neumann Architecture
13
Von Neumann architecture
14
Harvard Architecture
15
Harvard architecture
16
Difference between Von Neumann and Harvard Architecture
17
Arm Cortex-M0+ hardware overview
18
Key advantages of Arm Cortex-M0+ MCUs
21
Analog I/O
22
…
23
ADC/DAC
24
Communication :
Parallel, USB/Serial, UART, SPI, TWI, Ethernet, Wireless
• Communication between electronic devices is like communication
between humans.
• Both sides need to speak the same language.
• In electronics, these languages are called communication protocols.
• Luckily for us, there are only a few communication protocols
(SPI,I2C,UART,USB) we need to know when building most
electronics projects.
• SPI, I2C, and UART are quite a bit slower than protocols like USB,
Ethernet, Bluetooth, and Wi-Fi, but they’re a lot simpler and use less
hardware and system resources.
• SPI, I2C, and UART are ideal for communication between
microcontrollers and between microcontrollers and sensors where
large amounts of high speed data don’t need to be transferred.
25
Data Communication Types
– Parallel
– Serial
Parallel Communication:
• In parallel communication, all the bits of data are transmitted
simultaneously on separate communication lines.
– Used for shorter distance.
– In order to transmit n bit, n wires or lines are used.
– More costly.
– Faster than serial transmission.
– Data can be transmitted in less time
26
…
Serial Communication
• In serial communication the data bits are transmitted serially
one by one i.e. bit by bit on single communication line
• It requires only one communication line rather than n lines to
transmit data from sender to receiver.
• Thus all the bits of data are transmitted on single lines in serial
fashion.
• Less costly.
• Long distance transmission.
27
Serial communication uses two methods
– Asynchronous.
– Synchronous.
Asynchronous
• transfers single byte at a time
• No need of clock signal
Example: UART (universal asynchronous receiver transmitter)
Synchronous
• Transfers a block of data (characters) at a time.
• Requires clock signal
Example: SPI (serial peripheral interface)
I2C (inter integrated circuit).
28
…
29
…
31
…
32
SPI Communication Protocol
34
…
35
I2C Communication Protocol
36
…
37
…
• This is really useful when you want to have more than one
microcontroller logging data to a single memory card or
displaying text to a single LCD.
• IIC protocol uses two wires for data transfer between devices:
Serial Data Line (SDA) and Serial Clock Line (SCL).
• The reduction in number of pins in comparison with parallel
data transfer is evident.
• This reduces the cost of production, package size and power
consumption.
• IIC is also best suited protocol for battery operated devices.
• IIC is also referred as two wire serial interface (TWI).
38
…
39
Universal Serial Bus (USB)
40
ATmega32 microcontroller Architecture
41
Atmel Atmega32 highlights
43
…
44
Atmel Atmega32
⚫ Central Processing Unit
⚫ Arithmetic Logic Unit (ALU) performs
the actual arithmetic, logical, and bit-
functions
⚫ Memory – SRAM, EEPROM, Flash
⚫ Clock circuit – internal/external
⚫ I/O – Input/Output; video, serial, parallel,
USB, SCSI, etc.
45
3 Separate on-chip memories
46
Flash Program Memory layout
47
Most general-purpose microprocessors (like in your PC)
use a von Neumann Architecture
1. Data and instructions are both stored in the same main
memory
2. The content of any part of memory is addressable by
location without regard to what is stored in that location
program or data
3. Instructions are executed sequentially. In case of accidental
or intentional programming errors, data can be executed a
common attack used by viruses
48
Assembly language Programming with ATmega32
Instruction Set
• To code in assembler, one should have some idea about the
architecture of the target hardware.
• It is enough to assume that the AVR micro-controller appears
to the programmer as a set of General Purpose Registers
(GPRs: R1 to R31), Special Functions Registers (SFRs) that
controls the peripherals, some data memory (2kbytes of
SRAM for Atmega32).
• All of them are in the data address space.
• We also have Program memory and EEPROM in different
address spaces.
• Assembly language programming involves moving data between GPRs,
SFRs and RAM, and performing arithmetic and logical operations on
the data.
49
…
50
…
• The ALU can only directly operate on data that has been
fetched into the Registers.
• It cannot directly operate on SRAM or EEPROM data.
• In the assembly language instruction add r20, r5
– We (the programmer) must first load some values into these
registers.
– One way of doing this is with the following instructions:
ldi r20, 2 ; load value 2 into r20
lds r5, 0x60 ; load value at SRAM addr 0x60 into r5
add r20, r5 ; add them, result is in r20
51
General Purpose Registers
52
Special-purpose Registers can also be operated upon directly by the
ALU (with certain specific instructions)
53
Yet another Development System: AVRStudio
54
Programming in C to Interface peripherals, Interrupts,
ISR and Timers
• Interrupt: An interrupt is a signal sent to the CPU which
indicates that a system event has a occurred which needs
immediate attention.
• Interrupt ReQuest (IRQ) can be thought of as a special
request to the CPU to execute a function(small piece of code)
when an interrupt occurs.
• ISR : This function or small piece of code is technically called
an Interrupt Service Routine or ISR.
– So when an IRQ arrives to the CPU, it stops executing the current
code and start executing the ISR. After the ISR execution has
finished the CPU gets back to where it had stopped.
55
…
56
The End