ece 372 – microcontroller design parallel io ports - outputs
DESCRIPTION
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs. Parallel IO Ports E.g. Port T, Port AD Used to interface with many devices Switches LEDs LCD Keypads Relays Stepper Motors - PowerPoint PPT PresentationTRANSCRIPT
1
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
Parallel IO Ports E.g. Port T, Port AD Used to interface with many devices
Switches LEDs LCD Keypads Relays Stepper Motors
Interface with parallel IO requires us to connect the devices correctly and write code to interface with the devices
2
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
HCS12 – Where can we connect external hardware?
Unused ports (every port has DIO functionality) Expand through the serial interface SPI serial peripheral interface SCI serial communication interface RS232
3
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
HCS12 – Where can we connect external hardware?
Port B and A are not connected except PB4 and PA0 Port S0,1 is RxD and TxD for SCI Port M2,3,4,5 are used for SPI Port M0,1 are used for CAN Port P is cross connected with Port T except PP5 Port T0..7 can be sued for timer I/O and PWM Port A/D 0...7 is used for A/D input
4
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
Directly Controlling LEDs HCS12 can directly control LED from output ports Why would we NOT want to do this?
Micro-controlle
r
5V5V
5V5V
5
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
Simple LED Output Port is High - LED is On
7405 inverter output will be low Current flows through 7405 to ground
Output Port is Low – LED is Off 7405 inverter output will be high impedance No current flows through 7405
Resistor used to control brightness: LED is about 2V, 10-20mA
6
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
LED – Open Collector NPN transistor is On if Vb is High LED will be On is Vb is High Can support up to 250mA
NPN
CMicro-
controller
7
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
LED – Open Emitter PNP transistor is On if Vb is Low LED will be On is Vb is Low Can support up to 250mA
PNP
E
Micro-controlle
r
8
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
Directly Controlling LEDs We can use external IC to drive the LEDs
Reduce current driven by microcontroller and protects it 74LS244IC Tri-state Buffer/Line Driver/Line Receiver
Used to provide power for LEDs Has OE signals that can be used to disable the output
OE1
A8A7A6A5A4A3A2A1
A8A7A6A5A4A3A2A1
OE2
74LS244
Micro-controlle
r
9
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
Directly Controlling LEDs Limitation - Can only drive as many LEDs as available pins Solutions:
Latching Scanning Multiplexing
OE1
A8A7A6A5A4A3A2A1
A8A7A6A5A4A3A2A1
OE2
74LS244
Micro-controlle
r
10
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
LEDs - Latching Control LED by using a latch hardware Use additional hardware to control when to latch values
Similar to memory mapped IO
Latch
OE
A8
A7
A6
A5
A4
A3 A2
A1
A8
A7
A6
A5
A4
A3 A2
A1
LE
Latch
OE
A8
A7
A6
A5
A4
A3 A2
A1
A8
A7
A6
A5
A4
A3 A2
A1
LE
Micro-controlle
r
Address=0 Address=1
LED Data
LED Address
11
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
LEDs - Latching Control LED by using a latch hardware Use additional hardware to control when to latch values
Similar to memory mapped IO
Latch
OE
A8
A7
A6
A5
A4
A3 A2
A1
A8
A7
A6
A5
A4
A3 A2
A1
LE
Latch
OE
A8
A7
A6
A5
A4
A3 A2
A1
A8
A7
A6
A5
A4
A3 A2
A1
LE
Micro-controlle
r
Address=0 Address=1
Always writing last LED value!
Any problems??Addr
12
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
LEDs - Latching Add enable signal from microcontroller
Latch
OE
A8
A7
A6
A5
A4
A3 A2
A1
A8
A7
A6
A5
A4
A3 A2
A1
LE
Latch
OE
A8
A7
A6
A5
A4
A3 A2
A1
A8
A7
A6
A5
A4
A3 A2
A1
LE
Micro-controlle
r
Address=0 Address=1
AddrEn
What did we build?Is there another way to implement the address
decoding?
13
LEDs - Latching Use decoder for addressing LED banks
Decoder - Converts input binary number to single high output
2-input decoder: four possible input binary numbers Thus, four outputs, one for each possible input binary number
Enable signal Outputs all 0 if e=0 Regular behavior if e=1
i0
d0
d1
d2
d3
i1
i0
i1
d0
d1
d2
d3e
i1’i0’
i1’i0
i1i0’
i1i0
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
14
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
LEDs - Latching Use decoder for addressing LED banks
Latch
OE
A8
A7
A6
A5
A4
A3 A2
A1
A8
A7
A6
A5
A4
A3 A2
A1
LE
Latch
OE
A8
A7
A6
A5
A4
A3 A2
A1
A8
A7
A6
A5
A4
A3 A2
A1
LE
Micro-controlle
r
Address=0 Address=1
AddrEn i0
d0d1
en
1x2 Decoder
15
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
LEDs - Scanning Use software executing on the microcontroller to control LEDs row
by row, col by col, or bank by bank (depending on organization) Operation
Continually scan LEDs fast enough that human eye cannot detect it Similar to refresh rate of TVs and Monitors
Enable one column of LEDs by writing 0 to output port controlling desired column
Write LEDs value for select row Cannot access all LEDs simultaneously
Micro-controlle
r
Column Select
Row Data
16
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
LEDs - Multiplexed Use software executing on the microcontroller to control LEDs
one at a time Operation
Continually scan LEDs fast enough that human eye cannot detect it Similar to refresh rate of TVs and Monitors
Enable LED column by outputting column address to column decoder Enable individual LEDs by outputting row address to row decoder
Cannot access all LEDs simultaneously
Micro-controlle
r 4x16
dec
4x16
dec
17
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
How many LEDs can I control using only eight output pins using the following schemes?
Latched:
Scanned
Multiplexed:
18
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
How many LEDs can I control using only eight output pins using the following schemes?
Latched: 64 LEDs – Individual latch used for each LED 1 Enable Output, 6 Address Lines, and 1 Data Line Six address lines allow for access to 26 latches (or LEDs)
Scanned 16 LEDs – 4 columns by 4 rows
Multiplexed: 256 LEDs – 16 columns by 16 rows Enabled by using 4x16 decoder to select both row and
columns
19
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
Mill Game How many pins do we need to connect the 48 LEDs in the
following diagram?
20
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
Mill Game
21
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
7-Segment LEDs
Common Cathode
Micro-controlle
r
22
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
7-Segment LED – Design Example Control three 7-segment LED displays Scanning through the entire display must happen faster
than the human eye can detect (> 40 Hz) The LED must look like it is continuously on at 10 mA
Average current = 10 mA
23
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
7-Segment LED – Design Example Use scanning to control 7-segment LEDs
Micro-controlle
r
7447 – BCD to 7-Segment Display
24
ECE 372 – Microcontroller Design Parallel IO Ports - Outputs
7-Segment LED – Design Example Use scanning to control 7-segment LEDs
15 30
Time (ms)
Current (mA)
30
10 mA DC
1/15 ms > 66 Hz