ĐẠI HỌC QUỐC GIA TP.HỒ CHÍ MINHTRƯỜNG ĐẠI HỌC BÁCH KHOA KHOA ĐIỆN-ĐIỆN TỬ BỘ MÔN KỸ THUẬT ĐIỆN TỬ Embedded System Design Chapter 3: Hardware design for an embedded system... Bộ môn Kỹ
Trang 1ĐẠI HỌC QUỐC GIA TP.HỒ CHÍ MINH
TRƯỜNG ĐẠI HỌC BÁCH KHOA
KHOA ĐIỆN-ĐIỆN TỬ
BỘ MÔN KỸ THUẬT ĐIỆN TỬ
Embedded System Design
Chapter 3: Hardware design for an embedded
system
Trang 21
Trang 3– Sensors: temperature, humidity, light, motion
– Actuators: motor, solenoid, relay, FET, triac, SCR
– Interfaces: UART, USB, I2C, SPI, Ethernet, Wifi, Bluetooth, Zigbee
3 Clock / reset circuits
4 Power supply
– AC/DC adapters
– Battery
Trang 4Bộ môn Kỹ Thuật Điện Tử Chapter 4 2
Trang 51 Hardware components
• Microprocessors/Microcontrollers
– Is a center processing unit
– Control input devices, sensors, actuators, display devices
– Process tasks, functions, and algorithms
– Interface other systems
microprocessor
Trang 6Bộ môn Kỹ Thuật Điện Tử Example of an embedded system 3
Chapter 4
Trang 71 Hardware components
• Microprocessors/Microcontrollers
– The Intel MCS-51 (commonly referred to as 8051) is a Harvardarchitecture, CISC instruction set, single chip microcontroller (µC) series
– PIC is a family of modified Harvard architecture microcontrollers made
byMicrochip Technology
– ARM is a family of instruction set architectures for computer processors
instruction set computing (RISC) architecture
PIC
Trang 8Bộ môn Kỹ Thuật Điện Tử 4
Chapter 4
Trang 91 Hardware components
• Peripherals
– Input devices: button, switch, keyboard, mouse, touch-screen
– Display devices: LED, text LCD, graphic LCD
– Sensors: temperature, humidity, light, motion
– Actuators: motor, solenoid, relay, FET, triac, SCR
– Interfaces: UART, USB, I2C, SPI, Ethernet, Wifi, Bluetooth, Zigbee
Display device: LCD
Input device: keypad
Interface: UART
Trang 10Bộ môn Kỹ Thuật Điện Tử 5
Actuator: relay
Chapter 4
Trang 112 Design block diagram
• Block diagram
– Is a diagram of a system in which the principal parts or functions are represented by blocks connected by lines that show the relationships of the blocks
– Use to model the system graphically and show the
relationships in the process
– presents a quick overview of major process steps and key process participants, as well as the relationships and
interfaces.
Trang 12Bộ môn Kỹ Thuật Điện Tử Chapter 4 6
Trang 132 Design block diagram
• Hardware block diagram
– Use a rectangle for a hardware block
– Use an arrow for a connection
Single connection Multiple connections
Trang 14Bộ môn Kỹ Thuật Điện Tử Chapter 4 7
Trang 152 Design block diagram
• Hardware block diagram
– Use a symbol for a special block
computer Network
Trang 16Bộ môn Kỹ Thuật Điện Tử Chapter 4 8
Trang 172 Design block diagram
• Block diagram features:
– Block diagram name
– Physical blocks
• Block name
• Have at least one connection
– Connections
• One direction / two directions/ multiple directions
• Single / multiple connections
• Data type of connections
– Special block
Trang 18Bộ môn Kỹ Thuật Điện Tử
• Block name
• Extra information
9
Chapter 4
Trang 192 Design block diagram
• Recommendations
1 CPU block is at the center
2 Sensor/input blocks are at the left side
3 Actuator blocks are at the right side
4 User interface blocks are at the top
5 Memory/ database/ blocks are at the bottom
6 Use different colors for differently functional blocks
7 Use symbols for special blocks
• Exceptions
– Not enough space
– Special systems such as SoC, NoC
Trang 20Bộ môn Kỹ Thuật Điện Tử
– Complex systems
10
Chapter 4
Trang 22Bộ môn Kỹ Thuật Điện Tử 11
Trang 23Sabre lite board
Trang 24Bộ môn Kỹ Thuật Điện Tử 12
Trang 25Sabre lite board
Trang 26Bộ môn Kỹ Thuật Điện Tử 13
Trang 28Bộ môn Kỹ Thuật Điện Tử 14
Trang 30Bộ môn Kỹ Thuật Điện Tử 15
Trang 31DE2 board
Trang 32Bộ môn Kỹ Thuật Điện Tử 16
Trang 34Bộ môn Kỹ Thuật Điện Tử 17
Trang 36Bộ môn Kỹ Thuật Điện Tử 18
Trang 37Hardware block diagram – Example 1
• Poor example
– No block diagram name
– Wrong direction of connection
– Problem of single / multiple connections
– No data type of connections
PIC Microcontroller
Temperature
Heater
Trang 38Bộ môn Kỹ Thuật Điện Tử Chapter 4 19
Trang 39Hardware block diagram – Example 2
MOTOR CONTROL BLOCK DIAGRAM
Trang 40Bộ môn Kỹ Thuật Điện Tử Chapter 4 20
Trang 41Hardware block diagram – Example
Temperature monitor board
=> Make this block diagram better!
PIC Microcontroller
LCD16x2
Temperature
sensor
SIM900
Trang 42Bộ môn Kỹ Thuật Điện Tử Chapter 4 21
Trang 43Team work
• Draw the hardware block diagram of your project
Trang 44Bộ môn Kỹ Thuật Điện Tử 22
Trang 45Embedded system hardware
Trang 46Bộ môn Kỹ Thuật Điện Tử 23
Trang 47Micro controller selection
• Step1 Make a list of required hardware interfaces
Trang 48Bộ môn Kỹ Thuật Điện Tử 24
Trang 49Micro controller selection
• Examine the software architecture
– the algorithms require floating point
mathematics?
– Do we need special hardware like FPU, DMA – Are there any high frequency control loops or sensors?
– how long and how often each task will need to run?
– What interrupts will we need?
– How many timer will we need?
Trang 50Bộ môn Kỹ Thuật Điện Tử 25
Trang 51Micro controller selection
• Select the architecture
– Do we need to process 16/32 bit data often? – Can the application get by with 8/16 bit
architectures?
– Are there libraries that support the architecture
we chose?
Trang 52Bộ môn Kỹ Thuật Điện Tử 26
Trang 53Micro controller selection
• Identify Memory Needs
– What is the largest data structure?
– How much is the size of the RTOS/libraries we will use?
Trang 54Bộ môn Kỹ Thuật Điện Tử 27
Trang 55Micro controller selection
• Start searching for microcontrollers
– Supplier like Digikey, Arrow or other trusty
website.
– Chip manufacturer website (microchip, ST,TI,
Atmel, etc)
– https://en.wikipedia.org/wiki/List_of_common_m icrocontrollers
Trang 56Bộ môn Kỹ Thuật Điện Tử 28
Trang 57Micro controller selection
• Examine Costs and Power Constraints
– If the device will be powered from a battery and mobile, low-power feature is absolutely necessary – Price is very important with large quantity project
Trang 58Bộ môn Kỹ Thuật Điện Tử 29
Trang 59Micro controller selection
• Check part availability
– Are they kept in stock at multiple distributors or is there 6 – 12 week lead time?
– What are your requirements for availability?
– When will this part be obsolete? (life cycle)
Trang 60Bộ môn Kỹ Thuật Điện Tử 30
Trang 61Micro controller selection
• Step 8: Select a development kit
– Is there any development kit available?
• Step 9: Investigate compilers and tools,
Trang 62Bộ môn Kỹ Thuật Điện Tử 31
Trang 63Yes, with a device programmer
Entire Chip
Limited (consult datasheet)
Moderate Fast
Trang 64Bộ môn Kỹ Thuật Điện Tử 32
Trang 65Max Erase Cycles
Cost (per
Limited (consult datasheet)
Expensive
Fast to read, slow
to erase/writ e
Limited (consult datasheet)
Moderate
Fast to read, slow
to erase/writ e
Expensive
Trang 66Bộ môn Kỹ Thuật Điện Tử
battery) Fast
33
Trang 67Memory mapped bus
/WR /RD
/CS 1
/PSEN
CS2
27C256
/CS A<0 14> D<0 7> /OE
P0 P2 Q ALE /RD
Adr 7 0 Adr 15…8 Adr 7…0
Data
Trang 68Bộ môn Kỹ Thuật Điện Tử 34
Trang 69Memory mapped bus with 8051
VCC
U101
AT89C52
EA/VP 31
X1 19 X2 18
RESET 9
INT0 12 INT1 13 T0 14 T1 15
P1.0 1 P1.1 2 P1.2 3 P1.3 4 P1.4 5 P1.5 6 P1.6 7 P1.7 8
P0.0 39P0.1 38P0.2 37P0.3 36P0.4 35P0.5 34P0.6 33P0.7 32
P2.0 21P2.1 22P2.2 23P2.3 24P2.4 25P2.5 26P2.6 27P2.7 28
RD 17
WR 16PSEN 29
ALE/P 30
TXD
11 RXD 10
VCC
U102
74HC573
D0 2 D1 3 D2 4 D3 5 D4 6 D5 7 D6 8 D7 9 LE 11 OE 1
Q0 19Q1 18Q2 17Q3 16Q4 15Q5 14Q6 13Q7 12nEA
Y101 11.059MHz X1 X2
C102 30p C103 30p
P0.7
SW101
RESET
U106B 74HC00
4 5
6
P2.0 P2.2 P2.4 P2.6 ALE
RAM: 0x2000 - 0x3FFF
Dung de ZIF
A.0 A.2 A.4 A.6
A.13
nCS.3 A.15
MAIN
A.7
nCS.5
A.15 A.13
U106A 74HC00
1 2
3
VCC
A.12 GND
A.7 A.5 P0.[0 7]
P3.7 nRD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NC2 J9
A0 N3A1 P7A2 P3A3 N2A4 P8A5 P2A6 R8A7 R2A8 T8A9 R3A10/AP L7A11 R7A12/BC# N7A13 T3BA0 M2BA1 N8BA2 M3
CK J7CK# K7LDM E7UDM D3LDQS F3LDQS# G3UDQS C7UDQS# B7VSSQ1 B1VSSQ2 B9
VSS1 A9VSS2 B3VREFDQ H1 VSS4 G8VSS5 J2VSS3 E1VSS6 J8VSS7 M1VSS8 M9VSS9 P1VSS10 P9T1
VSSQ3 D1VSSQ4 D8VSSQ5 E2VSSQ6 E8VSSQ7 F9VSSQ8 G1VSSQ9 G9
VDDQ3 C1 VDDQ4 C9 VDDQ5 D2 VDDQ6 E9 VDDQ7 F1
VDD6 N1 VDD7 N9 VDD8 R1 VDD9 R9
L1 ZQ L8 VREFCA M8 RESET#
T2
A14 T7
VDDQ8 H2 VDDQ9 H9
DDR_D21 DDR_D23
DDR_D2
DDR_D18 DDR_D20 DDR_D7 DDR_D4 DDR_D6
DDR_DQS3P DDR_DQS3M DDR_RST
DDR_CKE0
DDR_A0
DDR_CS0N
DDR_CLKN DDR_CLK DDR_A1
R58 240R%1
DDR_D28 DDR_D31
DDR_D24 DDR_D26 DDR_D29
VCCDR
DDR_A15
DDR_ODT1 DDR_CS1N
Trang 72Bộ môn Kỹ Thuật Điện Tử 36
VSS12 T9NC3 L9 NC5 M7 M7 NC4 VSS12 T9DDR_A15 DDR_A15
DDR3
Trang 73Basic protocol concepts
Trang 74Bộ môn Kỹ Thuật Điện Tử 37
Trang 75A strobe/handshake compromise
Trang 76Bộ môn Kỹ Thuật Điện Tử 38
Trang 77Parallel communication
• Multiple data, control, and possibly power wires
– One bit per wire
• High data throughput with short distances
• Typically used when connecting devices on same IC or same circuit board
– Bus must be kept short
• long parallel wires result in high capacitance values which requires more time to charge/discharge
• Data misalignment between wires increases as length increases
• Higher cost, bulky
Question:
Trang 78Bộ môn Kỹ Thuật Điện Tử 39
List some parallel communications and peripherals you know?
Trang 79Serial communication
• Single data wire, possibly also control and power wires
• Words transmitted one bit at a time
• Higher data throughput with long distances
– Less average capacitance, so more bits per unit of time
• Cheaper, less bulky
• More complex interfacing logic and communication protocol
– Sender needs to decompose word into bits
– Receiver needs to recompose bits into word
– Control signals often sent on same wire as data increasing protocol complexity
Trang 80Bộ môn Kỹ Thuật Điện Tử 40
Trang 82Bộ môn Kỹ Thuật Điện Tử 41
Trang 84Bộ môn 42
Trang 85– 3.4 Mbits/s and 10-bit addressing in fast-mode
• EPROMS, Flash, and some RAM memory, real-time clocks, watchdog timers, and microcontrollers
Trang 86Bộ môn Kỹ Thuật Điện Tử 43
Trang 88Bộ môn Kỹ Thuật Điện Tử 44
Trang 90Bộ môn Kỹ Thuật 45
Trang 91I2C bus structure
SDA
SCL
SDA SCL
SDA SCL
SDA SCL Start
A 6
A 5
A 0
R / w
A C K
D 8
D 7
D 0
A C K
S T
O P
From Servant
From receiver
Typical read/write cycle
Trang 92Bộ môn Kỹ Thuật Điện Tử 46
Trang 93SPI bus
speeds– 0-50 MHz clock speeds not uncommon
characters
Bus wires
• Master-Out, Slave-In (MOSI)
• Master-In, Slave-Out (MISO)
• System Clock (SCLK)
• Slave Select/Chip Select (SS1#, …,
Trang 94Bộ môn Kỹ Thuật Điện Tử 47
SS#n or CS1, …, CSn)
Trang 95Bus configuration
Trang 96Bộ môn Kỹ Thuật Điện Tử 48
Trang 97SPI clocking
• Four clocking “modes”
– Two phases
– Two polarities
• Master and selected slave must be in the same mode
• During transfers with slaves A and B, Master must
– Configure clock to Slave A’s clock mode
Trang 98Bộ môn Kỹ Thuật Điện Tử 49
• Master reconfigures clock mode on-the-fly!
Trang 99SPI clock modes
Trang 100Bộ môn Kỹ Thuật Điện Tử 50
Trang 101SPI pros and cons
• Pros
– Fast for point-to-point connections
– Easily allows streaming/constant data inflow
– No addressing in protocol, so it’s simple to implement – Broadly supported
Trang 102Bộ môn Kỹ Thuật Điện Tử 51
– No flow control (must know slave speed)
Trang 103Other board bus
• One wire
• USB
• PCI
• LVDS
Trang 104Bộ môn Kỹ Thuật Điện Tử 52