You are on page 1of 27

ELEC 3300

Introduction to Embedded Systems

Topic 3
Embedded System Structure
Prof. Tim Woo

ELEC 3300 : Spring 17/18 Tim Woo 1


Course Overview
Assembler

Instruction Set Architecture

Memory I/O System

Datapath & Control


Introduction to Basic Computer
Embedded Systems Structure
MCU Main Board

Digital and Analog


Interfacing USART, IEEE1394,
USB, I2C and SPI

Microcontroller Structure
A/D Port
Buffering and
Serial Port Direct Memory Access
CPU
(DMA)
External Memory Port
Memory,
Interfacing to Memory,
External Interrupt Port
Memory Timing
Interrupt and applications
External Timer Port Interfacing LCD
Organization Timer and
Counter Simple I/O Port
Motor Interfacing

In this course, STM32 is used as a driving vehicle for delivering the concepts.
To be covered In progress Done

ELEC 3300 : Spring 17/18 Tim Woo 2


Expected Outcomes
• On successful completion of this topic, you will be able to
– Summarize the features of ARM micro-controller
– Illustrate examples of the pin definitions of several features
– Describe the bus architecture
– Understand the memory organization and its map
– Introduce the CRC calculation unit
– Configure a General Purpose I/O for input / output signal
– Analyze CPU Timing diagram of instruction codes

ELEC 3300 : Spring 17/18 Tim Woo 3


Microcontroller Features

• Processor with memory & I/O parts integrated on the same chip
• Program memory : ROM / EPROM / Flash
• Data memory: RAM / SRAM / Flash

Buses: Data / Address / Control


I/O ports

Others: Timers and Interrupts

Simple computation model (i.e. fetch-execute cycle) Any operating system support ?

You have to write your own device drivers to


control the external devices

ELEC 3300 : Spring 17/18 Tim Woo 4


ARM Microcontroller: Features of STM32

• Usually, there are 3 general documents for your reference:


• Data sheet: STM32F103ZET6-STMicroelectronics-datasheet-7543760.pdf
• Provides summary of features, pin layouts, pin definitions, electrical
characteristics, etc.

• Reference Manual: STM32_Reference_Manual.pdf


• Provides complete information on how to use the processor such
registration information of communication protocol, ADC, etc.
• This could help in writing the codes for initialization and
implementation.

• Programming Manual: STM32_Cortex_M3_Programming_Manual.pdf


• Provides information for application and system-level software, such
as efficient processor core, system and memories, fast interrupt
handling, etc.

ELEC 3300 : Spring 17/18 Tim Woo 5


ARM Microcontroller: Features of STM32
Where are they?
Program memory

CPU
Data memory

I/O port
Buses

ELEC 3300 : Spring 17/18 Tim Woo 6


ARM Microcontroller: High density pin definitions
• In general, all the features are not executed in most applications.
• This allows the sharing of pin definition for several features.
• Reference: Table 5 in datasheet *

Recall the overview pictures Pins assignment iin


STM32
Microcontroller Structure
A/D Port 15-18, 23-26, 29-36 (ADC1)

Serial Port (ADC2)


CPU
External Memory Port

External Interrupt Port

Interrupt External Timer Port


Organization
Timer and 1-5, 7-9, 14-18, 23-26, 29-48,
Simple I/O Port
Counter 51-72, 76-93, 95-98

* : STM32F103ZET6-STMicroelectronics-datasheet-7543760.pdf

ELEC 3300 : Spring 17/18 Tim Woo 7


ARM Microcontroller: High density pin definitions
Signal Type (Inside the MCU) Physical Pin Assignment
Three Analog to -ADC1_IN0 -PIN23
Digital Converters -ADC1_IN1 -PIN24
-ADC1_IN2 -PIN25
adc1 -….. -PIN26
-ADC1_IN15 -PIN29
-PIN30
-ADC2_IN0
-PIN31
-ADC2_IN1
-ADC2_IN2 -PIN32
adc2 -….. -PIN35
-PIN36 16 pins
-ADC2_IN15
-PIN15
-ADC3_IN0 -PIN16
-ADC3_IN1 -PIN17 Total:
adc3 -ADC3_IN2 -PIN18 21 pins are employed
-ADC3_IN3
-PIN33
-ADC3_IN4
-ADC3_IN5 -PIN34
ADC12 has 16 inputs -ADC3_IN6
-PIN18
ADC3 has 13 inputs -ADC3_IN7 5 pins in 144pin
analog signals
-ADC3_IN8 -PIN19
packages. Not
-… -PIN20
available in 100pin
-ADC3_IN13 -PIN21 package
ELEC 3300 : Spring 17/18 Tim Woo -PIN22 8
Class exercise 2: Design architecture of an embedded system

ELEC 3300 : Spring 17/18 Tim Woo 9


ARM Microcontroller: Bus architecture

• Bus Matrix : Master-slave configuration for general devices


Slave
Master

Master

Master
Slave

FLITF: Flash Memory Interface


FSMC: Flexible Static Memory Control
AHB: Advanced High-performance Bus
ELEC 3300 : Spring 17/18 Tim Woo APB: Advanced Peripheral Bus 10
ARM Microcontroller: Bus architecture

• Bus Matrix : Master-slave configuration for connectivity line


devices Slave
Master
Slave
Master

Master

Connectivity Lines Ethernet MAC: Media Access Control


USB OTG FS: USB on-the-go full-speed

ELEC 3300 : Spring 17/18 Tim Woo 11


ARM Microcontroller: Memory Map
Base addresses

• Memory plays an important role in the


micro-controller. It tells you where to
store and read the instructions, data,
status of information.

• Reference: Figure 9 in datasheet *

Data segment

Code segment

Base addresses
* : STM32F103ZET6-STMicroelectronics-datasheet-7543760.pdf
ELEC 3300 : Spring 17/18 Tim Woo 12
ARM Microcontroller: Memory Map
Base addresses

• It also tells you where to registers for


different features.

• Reference: Figure 9 in datasheet *


Register for ADC1
Register for Port D Base addresses

* : STM32F103ZET6-STMicroelectronics-datasheet-7543760.pdf
ELEC 3300 : Spring 17/18 Tim Woo 13
ARM Microcontroller: CRC Calculation Unit

• CRC (Cyclic Redundancy Check)


– Verify data transmission or storage integrity.
– Ability to have error detection and error correction for small number of
error bits via the transmission
#

Data decryption

Data encryption

# : STM32_Reference_Manual.pdf

ELEC 3300 : Spring 17/18 Tim Woo 14


Example: Connect a switch to MCU board
Description
Abstract idea of project
(Define the functionality of the system)
Data format / representation
Programming Language
Communication Protocol
Physical connection (Pins assignment)
Hardware devices
(Microcontroller, Peripherals)

Physical Pin Signal Type Initialization Signals at Data format


Devices Assignment (Configuration) Physical
connection
Micro Switch General Input / Output General On/Off
Purpose Input Purpose IO
& Output setting

Initialization implementation

Programming Language
ELEC 3300 : Spring 17/18 Tim Woo 15
Example: General-purpose I/O (GPIO)
#

We will use
these registers

# : STM32_Reference_Manual.pdf

ELEC 3300 : Spring 17/18 Tim Woo 16


Example: Connect a switch to MCU board
• All GPIO pins have an internal weak pull-up
and weak pull-down which can be activated or
not when configured as input.

Initialization

# : STM32_Reference_Manual.pdf

ELEC 3300 : Spring 17/18 Tim Woo 17


Example: General-purpose I/O (GPIO)

Pull-up resistor

ELEC 3300 : Spring 17/18 Tim Woo 18


Example: Connect a switch to MCU board
• In the programming, we have two steps
– Initialization for digital input
• Set CNF1 = 1, CNF0 = 0, Mode1/0 = 00
• Set PxODR = 0 or 1 (depends on the connection of switch)
– Implementation Start

• Write a routine for reading signal (Polling or Interrupt Driven) Initialization


(input port)
#

Read
Yes
Next operation ?
No

End
Initialization
# : STM32_Reference_Manual.pdf
ELEC 3300 : Spring 17/18 Tim Woo 19
Example: Connect a switch to MCU board
• Implementation
– Write a routine for reading signal (Polling or Interrupt Driven)
– Either polling or interrupt driven I/O, we can implement following flow
charts.
Start Start

Initialization
(input port) Initialization
(input port)

Read Read
Yes Yes
Next operation ? Next operation ?
No No Note:
The data is stored in
Data Input Register.
End End

ELEC 3300 : Spring 17/18 Tim Woo 20


Example: Connect a LED to MCU board
Description
Abstract idea of project
(Define the functionality of the system)
Data format / representation
Programming Language
Communication Protocol
Physical connection (Pins assignment)
Hardware devices
(Microcontroller, Peripherals)

Physical Pin Signal Type Initialization Signals at Data format


Devices Assignment (Configuration) Physical
connection
LED General Input / Output General On/Off
Purpose Input Purpose IO
& Output setting

Initialization implementation

Programming Language
ELEC 3300 : Spring 17/18 Tim Woo 21
Example: Connect a LED to MCU board
• When configured as output, the value written
to the Output Data register (GPIOx_ODR) is
output on the I/O pin.
• It is possible to use the output driver in Push-
Pull mode or Open-Drain mode (only the N- Start
MOS is activated when outputting 0).
Initialization
#
(output port)

Write
Yes
Next operation ?
No

End

# : STM32_Reference_Manual.pdf
ELEC 3300 : Spring 17/18 Tim Woo 22
Example: Bi-directional I/O port
• How can we initialize an general purpose I/O pin as a bi-directional one?
• If yes, how does the flow chart look like?

Start
Input Output
Input / Output ?

Initialization Initialization
(Input) (Output)

Read Write

Yes Yes
Next Next
Read operation ? Write operation ?
No No
Yes Yes
Write operation? Read operation?
No No
MCU sends out
End Start Signal
DHT sends out
Response
Signal

ELEC 3300 : Spring 17/18 Tim Woo 23


About Timing Diagram
• The timing diagram represents a set of signals in the time domain. It
describes how the device is being operated.
– Example: the timing diagram of the port P1 when the following instructions
are executed one-by-one. 1 machine cycle 1 machine cycle
MOV P1, R0 ; at time 0; R0 = 36H
R0 R0 R1
MOV P2, R4 ; at time 1; R4 = 4AH
MOV P1, R1 ; at time 2; R1 = 58H P1.7

P1.6
Assume all are 8-bit ports P1.5

P1.4

P1.3

P1.2
P1.1

P1.0

Time 0 Time 1 Time 2


ELEC 3300 : Spring 17/18 Tim Woo 24
About Timing Diagram
• For simplicity, it usually represents as
MOV P1, R0 ; at time 0; R0 = 36H
MOV P2, R4 ; at time 1; R4 = 4AH Assume all are 8-bit ports
MOV P1, R1 ; at time 2; R1 = 58H

Update the value


Keep the value
Update the value

R0 R0 R1
P1 36H 36H 58H

P2 unknown 4AH 4AH


Old value R4 R4

Time 0 Time 1 Time 2

Keep the value Update the value


Keep the value

ELEC 3300 : Spring 17/18 Tim Woo 25


Course Overview
Assembler

Instruction Set Architecture

Memory I/O System

Datapath & Control


Introduction to Basic Computer
Embedded Systems Structure
MCU Main Board

Digital and Analog


Interfacing USART, IEEE1394,
USB, I2C and SPI

Microcontroller Structure
A/D Port
Buffering and
Serial Port Direct Memory Access
CPU
(DMA)
External Memory Port
Memory,
Interfacing to Memory,
External Interrupt Port
Memory Timing
Interrupt and applications
External Timer Port Interfacing LCD
Organization Timer and
Counter Simple I/O Port
Motor Interfacing

In this course, STM32 is used as a driving vehicle for delivering the concepts.
To be covered In progress Done

ELEC 3300 : Spring 17/18 Tim Woo 26


Reflection (self-evaluation)
• Do you
– Describe the features of ARM micro-controller ?
– Illustrate other examples of the pin definitions of multiple features?
– Describe the bus architecture?
– Understand the memory organization and its map?
– Introduce the CRC calculation unit?
– Configure General Purpose I/Os for reading 3 digital input signals?
– Read CPU Timing diagram of instruction codes?

ELEC 3300 : Spring 17/18 Tim Woo 27

You might also like