5.3 Chip LSI thường dùng làm cổng I/O• PPI 8255 • Khi số lượng cổng I/O nhiều và không cố định • Cách mắc mạch sẽ quyết định địa chỉ cho các cổng còn vai trò của cổng sẽ được quyết địn
Trang 1Chương 5 Thiết kế các cổng I/O
5.1 I/O được phân vùng nhớ và I/O tách biệt
- I/O được phân vùng nhớ (Memory Mapped I/O)
- I/O tách biệt (Isolated I/O)
5.2 Các chip MSI dùng làm cổng I/O
- Cổng ra
- Cổng vào
5.3 Chip 8255
Trang 25.1 Cần phân biệt 2 kiểu thiết kế
• I/O được phân vùng nhớ (Memory mapped I/O):
- 1 cổng được xem như một ô nhớ
- 1 cổng có địa chỉ 20-bit
- được truy cập khi IO/M = 0
- không cần mạch giải mã địa chỉ riêng
• I/O tách biệt (isolated I/O)
- 1 cổng được xem đúng là 1 cổng
- 1 cổng có địa chỉ 16-bit, 12-bit, 8-bit
- được truy cập khi IO/M = 1
- cần mạch giải mã địa chỉ I/O riêng
Trang 35.2 Các chip MSI thường dùng làm cổng I/O
• 74LS373 :mạch cho phép chốt dịa chỉ khi LE=1 và OE=0
• 74LS374
• 74LS244: chip đệm 1 chiều khi D=H
• 74LS245:chip đệm 2 chiều, khi DIR=1 dữ liệu đi từ A-B,khi DIR=0 dữ liệu đi từ B-A
• Khi số lượng cổng ít và cố định
Trang 4Sử dụng 74LS245 làm cổng ra
: mov al, 55 mov dx, F000 out dx, al :
8088 Minimum Mode
A18 A0 :
D7 D6
IOR IOW
A19
D5 D4 D3 D2 D1 D0
74LS245
B0 B1 B2 B3 B4 B5 B6 B7
A0 A1 A2 A3 A4 A5 A6 A7
A 1 5
A 1 4
A 1 3
A 1 2
A 1 1
A 1 0
A 9
A 8
A 7
A 6
A 5
A 4
A 3
A 2
A 1 A
0 IOW
Trang 5Sử dụng 74LS373 làm cổng ra
8088 Minimum Mode
A18 A0 :
D7 D6
IOR
A19
D5 D4 D3 D2 D1 D0
74LS373
Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7
D0 D1 D2 D3 D4 D5 D6 D7
OE LE
Trang 6A 1 5
8088 Minimum Mode
A18 A0 :
D7 D6
IOR IOW
A19
D5 D4 D3 D2 D1 D0
A 1 4
A 1 3
A 1 2
A 1 1
A 1 0
A 9
A 8
A 7
A 6
A 5
A 4
A 3
A 2
A 1
A0 A1 A2 A3 A4 A5 A6 A7
Trang 7Cổng ra
Trang 8Cổng vào
Trang 95.3 Chip LSI thường dùng làm cổng I/O
• PPI 8255
• Khi số lượng cổng I/O nhiều và không cố định
• Cách mắc mạch sẽ quyết định địa chỉ cho
các cổng còn vai trò của cổng sẽ được
quyết định bởi phần mềm
Trang 108255 PPI
Trang 11Sơ đồ khối chức năng của 8255
Trang 12Các mode làm việc
• Mode 0
- PA, PB, PCH (CU) và PCL (CL)
- Có thể là Input hoặc Output
- Việc Nhập hoặc Xuất dữ liệu là độc lập
• Mode 1
- PA, PB
- Có thể là Input hoặc Output
• Mode 2
- PA
- PA vừa là Input vừa là Output
Trang 13Nhóm làm việc
• Nhóm A: PA và PCH
• Nhóm B: PB và PCL
• Định cấu hình làm việc cho 1 chip 8255:
thanh ghi điều khiển của chip đó
Trang 14Từ điều khiển định cấu hình làm việc cho một chip 8255
Trang 15Từ điều khiển lập/xoá bit cho một chip 8255
Trang 1616
Trang 1818
Trang 2020
Trang 22The 8255 Programmable Peripheral Interface
• Intel has developed several peripheral controller chips designed to support the 80x86 processor family The intent is to provide a complete I/O interface in one chip
• 8255 PPI provides three 8 bit input ports in one 40 pin package making it more
economical than 74LS373 and 74LS244
• The chip interfaces directly to the data bus of the processor, allowing its functions to be programmed; that is in one application a port may appear as an output, but in another,
by reprogramming it as an input This is in contrast with the 74LS373 and 74LS244
which are hard wired and fixed
8255 Pins
• PA0 - PA7: input, output, or bidirectional port
• PB0 - PB7: input or output
• PC0 - PC7: This 8 bit port can be all input or output It can also be split into two parts,
CU (PC4 - PC7) and CL (PC0 - PC3) Each can be used for input and output
• RD or WR
– IOR and IOW of the system are connected to these two pins
• RESET
• A0, A1, and CS
– CS selects the entire chip whereas A0 and A1 select the specific port (A, B, or C) or Control Register
Trang 23Giải mã địa chỉ cho 8255
Trang 24Mode 0 - Simple input/output
• Simple I/O mode: any of the ports A, B, CL, and CU can be programmed as input or output
• Example: Configure port A as input, B as output, and all the bits of port C as output assuming a base address of 50h
• Control word should be 1001 0000b = 90h
Mode 1: I/O with Handshaking Capability
• Handshaking refers to the process of communicating back and forth between two intelligent devices
• Example Process of communicating with a printer
– a byte of data is presented to the data bus of the printer
– the printer is informed of the presence of a byte of data to be printed by
activating its strobe signal
– whenever the printer receives the data it informs the sender by
activating an output signal called ACK
– the ACK signal initiates the process of providing another byte of data to
the printer
• 8255 in mode 1 is equipped with resources to handle handshaking
signals
Trang 25Mode 1 Strobed Output Signals
• OBFa (output buffer full for port A)
– indicates that the CPU has written a byte of data into port A
– must be connected to the STROBE of the receiving equipment
• ACKa (acknowledge for port A)
– through ACK, 8255 knows that data at port A has been picked up by the receiving device
– 8255 then makes OBFa high to indicate that the data is old now OBFa will not go low
Trang 26– Through IBF it indicates that it has latched the data but it has not been
read by the CPU yet
– To get the attention of the CPU, it IBF activates INTR
• INTR
– Falling edge of RD makes INTR low
– The RD signal from the CPU is of limited duration and when it goes high the 8255 in turn makes IBF inactive by setting it low
– IBF in this way lets the peripheral know that the byte of data was latched by the 8255 and read into the CPU as well
Trang 28Lập trình cho 8255
Trang 29Lời giải
Trang 30Lập trình cho 8255
Trang 31Lời giải
Trang 32Tạo chuỗi xung bằng phần mềm