Thursday, March 31, 2016

8051 Memory Mapped IO

The 8255 chip, one of the most widely used I/O chips. It has three separately accessible 8-bit ports. The individual ports of the 8255 can be programmed to be input or output, and can be changed dynamically. The 8255 is programmed as a simple I/O port for connection with devices such as LCDs, stepper motors, and ADCs.

8051 Memory Mapped IO

As seen above, the 8255 is connected to an 8051 as if it is RAM memory. Notice the use of RD and WR signals. This method of connecting an I/O chip to a CPU is called memory-mapped I/O, since it is mapped into memory space. In other words, we use memory space to access I/O devices. For this reason we use instructions such as MOVX to access the 8255. For an 8255 connected to the 8051 we must also use the MOVX instruction to communicate with it.

8255 Port Selection:
CS A1 A0 Selection
1 0 0 Port A
1 0 1 Port B
1 1 0 Port C
1 1 1 Port D
0 x x 8255 is not selected

Address Lines:
4000H 4001H 4002H 4003H
A0 0 1 0 1
A1 0 0 1 1
A2 X X X X
A3 X X X X
A4 X X X X
A5 X X X X
A6 X X X X
A7 X X X X
A8 X X X X
A9 X X X X
A10 X X X X
A11 X X X X
A12 X X X X
A13 X X X X
A14 1 1 1 1
A15 X X X X

Program to toggle bits in 8255 output ports:
MOV A, #80H ; configure ports as output
MOV DPTR, #4003H ; load control register address
MOV A, #55H
AGAIN :MOV DPTR, #4000H ; load port A address
INC DPTR ; load port B address
INC DPTR ; load port C address
CPL A ; toggle port bits
DELAY :MOV R3, #50
HERE2 :MOV R4, #255
HERE :DJNZ R4, HERE ; stay until R4 = 0
DJNZ R3, HERE2; stay until R3 = 0

Related topics:
8051 External Program Memory Interfacing   |   8051 External Data Memory Interfacing   |   8051 LED Interfacing   |   8051 Switch Interfacing   |   8051 Keyboard Interfacing   |   8051 7-Segment Display Interfacing   |   8051 LCD Interfacing   |   8051 ADC Interfacing   |   8051 DAC Interfacing   |   8051 Relay Interfacing   |   8051 Sensor Interfacing   |   8051 Stepper Motor Interfacing   |   8051 DC Motor Interfacing

List of topics: 8051

No comments:

Post a Comment