IO Ports
IO Ports
I/O Ports
DC Electrical Characteristics
EE3954
by
Maarten Uijt de Haag, Tim Bambeck
PORTE
PORTD
PORTC PORTC
PORTD PORTD
Buffers
Flip-Flops
Logic Gates
MOS Transistors
(Output Drivers)
I/O Pin
Voltage Current
Levels: Levels:
TTL Sink current
Schmitt Trigger Source current
CMOS Fan-in
Open drain Fan-out
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
PORT Writes:
movwf PORTX
movwf TRISX
PORT Reads:
movf PORTX,W
btfss PORTX,2
p-channel transistor 1
= Off
Source
Gate
P
0
Drain = On
n-channel transistor 1
= On
Drain
Gate
N
0
Source = Off
D
V2
N On Off
G
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:
Switching Positive-going
Vin threshold Vin Threshold (4v)
Negative-going
Threshold (1v)
t t
Vout Vout
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
Microcontroller I
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.
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
VDD
VSS I/O Part I.31
Laboratory #2
7-segment display
Microcontroller
RD7 RD6 RD5 RD4 RD3 RD2 RD1 RD0
I1 I2 I3 I1 I2 I3
Low High
I I
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
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)
PORTA, B, C, D, E Functions.
RED Circled is
POR Condition.
Blue Circled is
Example on
Next page.