Chapter 2
Chapter 2
Learning objectives:
• To know about hardware architecture of embedded system
• Understand the ARM Cortex M0+ Hardware Overview
• Arm Cortex-M0+ Ports and Interrupts
• Explain about serial and parallel communication
• Explain ATmega32 microcontroller Architecture
• Describe Assembly language Programming with
ATmega32 Instruction Set.
• Discuss about Interface peripherals, and Timers
1
EMBEDDED SYSEM HARDWARE
2
ARCHITECTURE OF AN EMBEDDED SYSTEM
4
Hardware architectures for embedded systems…
5
Hardware architectures for embedded systems…
Harvard Architecture
First named after the Harvard Mark I computer.
It emphasizes the separation of instructions and data memory.
It has separate physical and data buses for instructions and data,
Which allows simultaneous access to both instruction and data
memory.
This feature can result in faster and more efficient execution of
instructions, especially for applications with time-critical tasks, such
as real-time systems.
It is commonly found in microcontrollers and digital signal
processors that require high performance and deterministic behavior.
It was basically developed to overcome the bottleneck of Von
Neumann Architecture. 6
Hardware architectures for embedded systems…
7
Hardware architectures for embedded systems…
32-bit
• ARM processor is one of a family of CPU based
Year Core
on the RISC architecture developed by advanced
2004 Cortex-M3
RISC machine(ARM).
2007 Cortex-M1
• ARM processor are extensively used in consumer
electronic devices. Such as smart phone, tablet, 2009 Cortex-M0
12
Microprocessor(µP)
13
Microprocessor (Cont’d)
Set Computer (RISC) More line of code, more RAM is needed to Because the length of the code is relatively short, very little
store the assembly level instructions RAM is required to store instructions.
An instruction fit in one word Instructions are larger than the size of one word
Pipelining of instructions is possible, Pipelining is not possible.
considering single clock cycle.
E.g. For multiplication operation a RISC E.g. for multiplication operation a CISC processor would come
processor divides the instruction into three prepared with a specific instruction which can loads the two
separate commands as: values in to registers, multiply operands in execution unit and
LOAD A, 2:3 then store the product in register with one instruction.
LOAD B, 5:2 MULT 2:3, 5:2
PROD A, B Note: 2:3 and 5:2 are Memory locations 14
STORE 2:3, A
Microcontroller(µC)
15
Microcontroller …..(Cont’d)
16
Structure of Microcontroller
17
Microcontrollers versus Microprocessors
18
Microcontrollers versus Microprocessors.
19
Arm Cortex-M0+ Ports
• The single-cycle I/O port is memory mapped and supports all the
load and store instructions described in Memory access instructions.
20
PORT….
• Port in embedded: PORT is used to set the output value. • If the pin is
set as output, then a PORT value of 1 will set voltage at that pin to 5V.
If PORT value is 0, then voltage is set to 0.
21
PORT….contd
22
Registers
24
Register
o R15: Used as the program counter that points to the next instructions
to be executed.
In ARM state, all instructions are of 32-bits(four bytes).
• They work with digital signals but can be mixed to use the pins with
other peripheral functions (ADC, SSI, UART, etc).
• A GPIO port handles both incoming and outgoing digital signals.
Peripheral: GPIO
30
ADC and DAC
31
ADC and DAC….contd
32
Communication in Embedded Systems
• 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.
• Used for Long distance transmission.
• One huge advantage of having fewer wires/pins in a serial cable is the
significant reduction in the size, the complexity of the connectors, and the
associated costs.
• smartphones designers benefit from the development of connectors/ports that
are small, durable, and still provide adequate performance.
35
Modes of Data Transfer in Serial Communication
36
Modes of Data Transfer in Serial Communication(cont’d…)
Synchronous
• The clocks of the sender and receiver are unified, sending and receiving units are
enabled with same clock signal
• A common clock is shared by the transmitter and receiver to achieve synchronization
while data transmission.
• The master is designed to supply the data at a time when the slave is definitely ready
for it.
• Data is sent in frames or blocks.
• In synchronous transmission, the whole block of data bits is transferred at once, instead
of one character at a time like asynchronous
• Used when large amounts of data needs to be transferred from one location to the other.
• a method of sending large amounts of data.
37
Modes of Data Transfer in Serial Communication(cont’d…)
Synchronous
• The following instances of data transmission would be
considered synchronous:
o Transfer of large text files.
o Chatrooms.
o Video conferencing.
o Telephone conversation
38
Modes of Data Transfer in Serial Communication(cont’d…)
Asynchronous Transmission
• Also known as start/stop transmission
• Sends data from the sender to the receiver using the flow control method
• Data is synchronized between sender and the receiver without the use of a clock.
• Sends one character or 8 bits at a time, In total, 10 bits are transmitted, with a
start bit preceding the character, and a stop bit following it.
• In this method, before the transmission process begins, each character sends the
start bit. After sending the character, it also sends the stop bit. With the character
bits and start and stop bits, the total number of bits is 10 bits.
39
Modes of Data Transfer in Serial Communication(cont’d…)
Asynchronous Transmission
• In asynchronous transmission the receiver is
largely unaware of when data will arrive.
• There is no need to synchronize the
transmitter and receiver.
• Simple to implement.
• Overall slower transmission rate.
• Extra data is required in the form of start
and stop bits, increasing the overall size of
the transmitted data.
• There are many examples of asynchronous
transmission occurring all around us. These
include:
o Emails
o Forums
o Radios 40
Modes of Data Transfer in Serial Communication(cont’d…)
Parallel communication
Serial Communication protocol
protocol
44
ATmega32 Microcontroller Pin Diagram
PDIP- stands Plastic Dual Inline Package, and it is a type of packaging used for IC 45
ATmega32 Microcontroller Pin Diagram….contd
46
ATmega32 Microcontroller Pin Diagram….contd
47
ATmega32 Microcontroller Pin Descriptions
Interrupt Pins
• ATmega32 has three external hardware
interrupts on pins PD2, PD3, and PB2 which
are referred to as INT0, INT1, and INT2
respectively.
• ATmega controller gets interrupted in whatever
task it is doing and jumps to perform the
interrupt service routine.
• E.g. system temperature beyond limit can be an
interrupt
Analog to Digital Channel:
• There is a total of 8 analogs to digital channels
that can be used as ADC.
• are only in port A (ADC0-ADC7)
50
ATmega32 Microcontroller Pin Descriptions….contd
51
ATmega32 Microcontroller Pin Descriptions….contd
54
ATmega32 Instruction Set: Example
56
Timers