Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 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 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 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 is used for A/D input

4 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- controller 5V

5 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 6 ECE 372 – Microcontroller Design Parallel IO Ports - Outputs LED – Open Collector NPN transistor is On if V b is High LED will be On is V b is High Can support up to 250mA NPN C Micro- controller

7 7 ECE 372 – Microcontroller Design Parallel IO Ports - Outputs LED – Open Emitter PNP transistor is On if V b is Low LED will be On is V b is Low Can support up to 250mA PNP E Micro- controller

8 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 A8 A7 A6 A5 A4 A3 A2 A1 A8 A7 A6 A5 A4 A3 A2 A1 OE2 74LS244 Micro- controller

9 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 A8 A7 A6 A5 A4 A3 A2 A1 A8 A7 A6 A5 A4 A3 A2 A1 OE2 74LS244 Micro- controller

10 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 A8A7A6A5A4A3A2A1 A8A7A6A5A4A3A2A1 LE Latch OE A8A7A6A5A4A3A2A1 A8A7A6A5A4A3A2A1 LE Micro- controller Address=0Address=1 LED Data LED Address

11 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 A8A7A6A5A4A3A2A1 A8A7A6A5A4A3A2A1 LE Latch OE A8A7A6A5A4A3A2A1 A8A7A6A5A4A3A2A1 LE Micro- controller Address=0Address=1 Always writing last LED value! Any problems?? Addr

12 12 ECE 372 – Microcontroller Design Parallel IO Ports - Outputs LEDs - Latching Add enable signal from microcontroller Latch OE A8A7A6A5A4A3A2A1 A8A7A6A5A4A3A2A1 LE Latch OE A8A7A6A5A4A3A2A1 A8A7A6A5A4A3A2A1 LE Micro- controller Address=0Address=1 Addr En What did we build? Is there another way to implement the address decoding?

13 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 d3 e i1’i0’ i1’i0 i1i0’ i1i0 ECE 372 – Microcontroller Design Parallel IO Ports - Outputs

14 14 ECE 372 – Microcontroller Design Parallel IO Ports - Outputs LEDs - Latching Use decoder for addressing LED banks Latch OE A8A7A6A5A4A3A2A1 A8A7A6A5A4A3A2A1 LE Latch OE A8A7A6A5A4A3A2A1 A8A7A6A5A4A3A2A1 LE Micro- controller Address=0Address=1 Addr En i0 d0 d1 en 1x2 Decoder

15 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- controller Column Select Row Data

16 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- controller 4x16 dec

17 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 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 2 6 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 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 20 ECE 372 – Microcontroller Design Parallel IO Ports - Outputs Mill Game

21 21 ECE 372 – Microcontroller Design Parallel IO Ports - Outputs 7-Segment LEDs Common Cathode Micro- controller

22 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 23 ECE 372 – Microcontroller Design Parallel IO Ports - Outputs 7-Segment LED – Design Example Use scanning to control 7-segment LEDs Micro- controller 7447 – BCD to 7-Segment Display

24 24 ECE 372 – Microcontroller Design Parallel IO Ports - Outputs 7-Segment LED – Design Example Use scanning to control 7-segment LEDs Time (ms) Current (mA) mA DC 1/15 ms > 66 Hz


Download ppt "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."

Similar presentations


Ads by Google