0% found this document useful (0 votes)
66 views45 pages

IO Ports

The document discusses I/O ports on microprocessors and microcontrollers. It covers typical components of an I/O port including buffers, flip-flops, logic gates, and MOS transistors. It also discusses I/O pin electrical characteristics such as voltage levels, noise margins, and sink and source currents. The document uses examples from the PIC16F877 datasheet to illustrate these concepts.

Uploaded by

Ashwin S Sivan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views45 pages

IO Ports

The document discusses I/O ports on microprocessors and microcontrollers. It covers typical components of an I/O port including buffers, flip-flops, logic gates, and MOS transistors. It also discusses I/O pin electrical characteristics such as voltage levels, noise margins, and sink and source currents. The document uses examples from the PIC16F877 datasheet to illustrate these concepts.

Uploaded by

Ashwin S Sivan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

Microprocessors and Microcontrollers

I/O Ports
DC Electrical Characteristics

EE3954

by
Maarten Uijt de Haag, Tim Bambeck

I/O Part I.1


PORTB
PORTA

PORTE

PORTD

PORTC PORTC

PORTD PORTD

Multiplexing of I/O Pins I/O Part I.2


Pin Diagram from Datasheet
I/O Part I.3
Typical I/O Port

I/O Part I.4


Typical I/O Port

Buffers

I/O Part I.5


Typical I/O Port

Flip-Flops

I/O Part I.6


Typical I/O Port

Logic Gates

I/O Part I.7


Typical I/O Port

MOS Transistors
(Output Drivers)

I/O Part I.8


Overview
DC Electrical Characteristics

I/O Pin
Voltage Current

Levels: Levels:
TTL Sink current
Schmitt Trigger Source current
CMOS Fan-in
Open drain Fan-out

I/O Part I.9


Input/Output Ports
Most PORT pins can be defined as either input or output
via the TRIS registers.

PORTA, PORTB, PORTC, TRISA, TRISB, TRISC,


PORTD, PORTE TRISD, TRISE

To read/write data from/to Data Direction Registers


inputs/outputs Determines if a pin is an input
(1) or an output (0)
I/O Part I.10
Special Function Registers

STATUS
PORTs TRISs
are in are in
Bank 0 Bank 1 Bank 0: RP1 = 0; RP0 = 0
Bank 1: RP1 = 0; RP0 = 1
I/O Part I.11
I/O Ports
Example Part 1
PORTA equ 0x05
TRISA equ 0x05

org 0x000
nop

; Select Bank 1 to access the data direction registers (TRIS)


bcf STATUS, RP1
bsf STATUS, RP0

; Set pins 1, 2, 4, and 7 as input


; Set pins 0, 3, 5, and 6 as output
movlw B1001 0110
movwf TRISA

; Select Bank 0 to access the PORT itself


bcf STATUS, RP0

NOTE: 1 looks like an I for input


I/O Part I.12
0 looks like an O for output
I/O Ports
Example Part 2
; Select Bank 0 to access the PORT itself
bcf STATUS, RP0

; Check the input on 2 and call the subroutine SUB_1 if its is 1


btfsc PORTA, 2
call SUB_1



; Set the output on pin 5 to 0
bcf PORTA, 5


; Set the output on pin 0 to 1
bsf PORTA, 0

I/O Part I.13


NOTE: 1 looks like an I for input; 0 looks like an O for output
I/O Port
Equivalent Statements

PORTA is at Data Memory address 0x05 and


TRISA is at Data Memory address 0x85
7 least significant bits of 0x05
PORTA equ 0x05
TRISA equ 0x05 00 0000101 -> 0x05
01 0000101 -> 0x85

I/O Part I.14


Typical I/O Port Pin

PORT Writes:

movwf PORTX

movwf TRISX

I/O Part I.15


Typical I/O Port Pin

PORT Reads:

movf PORTX,W

btfss PORTX,2

I/O Part I.16


Typical I/O Port

I/O Part I.17


Transistor p-channel:

p-channel transistor 1
= Off
Source

Gate
P

0
Drain = On

I/O Part I.18


Transistor n-channel:

n-channel transistor 1
= On
Drain

Gate
N

0
Source = Off

I/O Part I.19


Totem Pole Configuration
VDD VDD VDD
V1 = VDD=1; V1 = VSS=0;
V2 = VDD=1 V2 = VSS=0
S
V1
G
P Off On
D I/O Pin 0 (VSS) 1 (VDD)

D
V2
N On Off
G

VSS VSS VSS I/O Part I.20


Interpretation Example
Writing to TRIS - Output

Here:
VSS = 0
VDD = 1
I/O Part I.21
Interpretation Example
Writing to a PORT Pin - Output

0
1 1
0
0
1 1
0
1
1

Here:
VSS = 0
VDD = 1
I/O Part I.22
Schmitt Trigger
Regular input buffer: Schmitt Trigger buffer:

Vin Vout Vin Vout

Switching Positive-going
Vin threshold Vin Threshold (4v)

Negative-going
Threshold (1v)

t t

Vout Vout

False switching occurs t Jitter free operation I/O Part I.23t


I/O Port
DC Electrical Characteristics

Output: Input:
(Minimum high-level output voltage)
VOH (Minimum high-level input voltage)
VIH

VIL
VOL (Maximum low-level input voltage)
(Maximum low-level output voltage)

Increasing voltage

See, for example, Datasheet Page 155/156 (157/158 in PDF)


I/O Part I.24
I/O Port
Noise Margin
5.0 v -> VDD
Guaranteed Recognizable
HIGH-level output HIGH-level output
4.3 v (min) -> VOH
Noise Margin
2.0 v -> VIH
Uncertain region (neither HIGH nor LOW)

0.75v -> VIL


Noise Margin
0.6v (max) -> VOL Recognizable
LOW-level output
0v ->
VSS = 0
Guaranteed
LOW-level output
I/O Part I.25
TTL Voltage Level
PIC16F877

VOL = 0.6V max


VOH = (VDD- 0.7) V min = 4.3V min
( values from page 156 in Data Sheets )

VIL = VSS -> 0.15 VDD = 0V -> 0.75V


VIH = 2.0 -> VDD = 2.0V > 5.0V
(values from page 155 in Data Sheets )

I/O Part I.26


I/O Ports
Sink and Source Currents

Sink current is the current going into the microcontroller

Microcontroller I

Source current is the current coming out of the microcontroller

Microcontroller I

See, for example, Datasheet Page 149 (151 in PDF) I/O Part I.27
I/O Ports
Sink and Source Currents PIC16F877

Any pin = 25 mA. Port A=6 pins, B=8 pins, E=3 pins for a total of 17 pins.

We would expect: 17 pins * 25 mA = 425 mA.


( Note: combined Port A,B,E is 200 mA max.)
I/O Part I.28
I/O Ports
Sink and Source Currents PIC16F877

If RD1 = 0 = VOL = 0V:


(A) No voltage differential between (A) and
RD1 (B), thus LED is OFF.

R If RD1 = 1 = VOH = 5V:


PIC 5V
Ohms Law: V = I*R
16F877 R
Voltage over resistor:
(B) 5 1.4 = 3.6V
1.4V
I = V/R = 3.6/R < 25mA
Thus,
R > 3.6/2510-3 = 144
PR= 3.6*2510-3 = 0.09W

NOTE: Voltage drop over the diode is ~1.4V I/O Part I.29
I/O Ports
Sink and Source Currents PIC16F877
With VOH and VOL
VOH = 4.3V & VOL = 0.6V
IOH = 25mA & IOL = 25mA
(A)
RD1 If RD1 = 0 = VOL = 0.6V:
Not enough voltage differential between
R (A) and (B), thus LED is OFF.
PIC If RD1 = 1 = VOH = 4.3V:
16F877
4.3V
(B) Ohms Law: V = I *
R R
Voltage over resistor:
1.4V 4.3 1.4 = 2.9V
I = V/R = 2.9/R < 25mA
Thus,
R > 2.9/2510-3 = 116
NOTE: Voltage drop over the diode is ~1.4V I/O Part I.30
Diodes

I I

Current only flows


through the diode in
one direction
VDD VSS

Works: Does not


Work:

VDD
VSS I/O Part I.31
Laboratory #2
7-segment display
Microcontroller
RD7 RD6 RD5 RD4 RD3 RD2 RD1 RD0

I/O Part I.32


Fan-out
Fan-out
The number of inputs (in the form of devices and gates) that can be driven
from a single device or gate output (or pin) without damaging the IC

I1 I2 I3 I1 I2 I3
Low High

I I

I/O Part I.33


Fan-out
Example
VOH = 5 V
RD1

470 470 470 470 470


PIC
16F877 Vdiode = 1.4V

Is this going to work???

Current through one of the LEDs = (5-1.4)/470 = 7.66mA

So, the total current that must be sourced by the pin is:
5*7.66mA = 38.3mA

So, 38.3mA > 25mA and therefore this is not going to work!!!
I/O Part I.34
Interpretation Example
Writing to TRIS - Input

1
1
open

0
1 open

Here:
VSS = 0
VDD = 1
I/O Part I.35
I/O Ports
High Impedance

I/O Part I.36


I/O Ports
High Impedance
V2 = VDD V2 = VSS
I/O Pin
RA4 (PORTA Pin 4) I/O Pin I/O Pin
= VSS= 0 =

V2 NMOS
N On Off

VSS
VSS VSS
Open Drain Output It looks as if there is a very high
impedance between the pin and ground
I/O Part I.37
I/O Ports
Pull-Up Resistor VDD VDD
VDD

0V 5V

On Off
V2
N

VSS VSS
V2 = VDD V2 = VSS
VSS
I/O Part I.38
I/O Ports
PIC16F877
See Datasheet Table 1-2 Page 8 & 9
(PDF pages: 10 & 11)

See Datasheet Pages 30 through 36 For:


(PDF pages: 32-38)

PORTA, B, C, D, E Functions.

Registers Associated with Each Port.

I/O Part I.39


PORT A
From Datasheet

PINS 0,1,2, and 3 are also used


as a 10-bit Analog-to-Digital Converter (ADC)
(Sections 21,22,23, and 24 of RM)
(Section 11 of DS)

SFR ADCON1 (see page 29 of DS) must be used to


configure PORTA as either a regular PORT or an ADC.
I/O Part I.40
From PIC16F877 Datasheet
PORT A - Configuration
ADCON1 @ 0x1F in Bank 1

RED Circled is
POR Condition.

Blue Circled is
Example on
Next page.

I/O Part I.41


PORT A
Configure as all digital I/O
BCF STATUS, RP0 ;
BCF STATUS, RP1 ; Bank0
CLRF PORTA ; Initialize PORTA by
; clearing output
; data latches
BSF STATUS, RP0 ; Select Bank 1
MOVLW B0000 0110 ; Configure all pins
MOVWF ADCON1 ; as digital inputs
MOVLW B1100 1111 ; Value used to
; initialize data
; direction
MOVWF TRISA ; Set RA<3:0> as inputs
; RA<5:4> as outputs
; TRISA<7:6>are always
; read as 0.
I/O Part I.42
PORT A
From Datasheet

I/O Part I.43


PORT B

I/O Part I.44


PORTB

I/O Part I.45

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy