-
Don't use 8255 anymore, there is no future, now multi-pin single-chip microcomputers are cheap and more, why do you have to use 8255
-
First, the status of 8 peripherals is read into AL through port A, then sent to AH, and then the status of the other 8 peripherals is read into AL through port B
In this way, there are 16 status signals for the peripherals in the AX.
How to determine '1' in ax:
Shift the content in AX to the left one place at a time, move the highest displacement into the cf in the flag register, determine whether the value of cf is 1, and move it left continuously for 16 times.
The procedure is as follows: mov bl,0; The number of 1s in AX is stored, and the initial value is 0mov cx,16; Initial value of the number of cycles.
next:shl ax,1
jnc go
inc bl
go:loop next
mov al,bl
It can also be written as: mov bl,0 ; The number of 1s in AX is stored, and the initial value is 0mov cx,16; Initial value of the number of cycles.
next:shl ax,1
adc bl,0;Directly add the value of the displaced cf to the blloop next
mov al,bl
Finally, the lower four bits in the AL are sent to the connected four light-emitting diodes through the C port.
-
There are 3 ways to work:
Method 0, Method 1, Method 2
Method 0 (Basic Input and Output Mode):
There is no need to select any signal, and the A, B, and C ports can be set as inputs or outputs with 4 bits high and C ports as low bits.
When the output port is used, the output data is locked; The input data is not locked when it is used as an input port.
Method 1 (strobe input and output mode):
The three mouths A, B, and C were divided into two groups.
Group A: including A port and high half C port, A port can be programmed to input or output, C port high 4 bits for IO control and synchronization signal;
Group B: including B port and low half C port, B port can be programmed to input or output, C port low 4 bits for IO control and synchronization signal;
The input and output data of port A and port B are all locked.
Method 2 (bidirectional bus mode):
A port (only A port) is used as an 8-bit bidirectional bus, and the PC3 and PC7 bits of C port are used for IO control and synchronization signals;
The PC0 and PC2 bits of the B port and C port can be programmed to work in mode 0 or mode 1.
-
The 8255A is not a microcontroller, but a peripheral chip of a microcontroller for expanding the parallel port. The basic functions are as follows:
1. There are three IO ports, namely A, B, and C ports.
2. A port: It is an independent 8-bit IO port, which has the latch function of data input and output.
3. B port: It is also an independent 8-bit I O port, which only has the latch function for the output data.
4. C port: It can be regarded as an independent 8-bit I O port; It can also be seen as two independent 4-bit I-O ports. It is also latched only on the output data.
-
Expansion of IO port;
Specifically, three 8-bit IO ports can be added.
That is, the 24-bit I.O. port.
-
The 8255 has 24 input/output pins, programmable, general-purpose parallel input-output interface circuitry. It is a 40-pin dual in-line LSI using a single +5V power supply. The 8255A is versatile and flexible, allowing the CPU to connect directly to peripherals.
8255A should write a mode control word before use, and select the working mode of the three ports A, B, and C, there are three in total;
Method 0: The basic input and output mode, that is, the IO method that can be carried out directly without contact. The upper four bits or the lower four bits of ports A, B, and C can be set as inputs or outputs respectively.
Method 1: Strobe IO, at this time the interface and the peripheral equipment need to contact the signal for coordination, only the A port and the B port can work in mode 1, at this time some lines of the C port are specified as the A port or B port and the peripheral equipment contact signal, the remaining line only has the basic I O function, that is, only work in mode 0
Method 2: Two-way I O mode, only A port can work in this way, the I O line can be input and output, at this time, there are 5 lines in C port is specified as a two-way contact line between A port and peripheral equipment, and the remaining three lines of C port can be used as the contact line of B port mode 1, and can also be used with B port with the I O line of mode 0. The 8255A is a parallel input and output device with 24 programmable I-O ports, including three groups of 8-bit I-O ports, PB ports, and PC ports, and can be divided into two groups of 12-bit I-O ports
Group A includes the upper 4 positions of A port and C port, and Group B includes the lower 4 positions of B port and C group.
Port A can be set to mode 0, mode 1, and mode 2, while ports B and C can only be set to mode 0 or mode 1
-
Method 0 (Basic Input and Output Mode):
There is no need to select any signal signal, and the A port, B port, high half C port, and low half C port can be set as input or output.
When the output port is used, the output data is locked; The input data is not locked when it is used as an input port.
Method 1 (strobe input and output mode):
The three mouths A, B, and C were divided into two groups.
Group A includes A port and high half C port, A port can be programmed to input or output, high half C port is used for I O control and synchronization signal;
Group B includes B port and low half C port, B port can be programmed to input or output, low half C port is used for IO control and synchronization signal;
The input and output data of port A and port B are all locked.
Method 2 (bidirectional bus mode):
A port (only A port) is used as an 8-bit bidirectional bus, and PC3 and PC7 bits of C port are used for IO control and synchronization signals;
PC0 and PC2 of B and C ports can be programmed to work in mode 0 or mode 1.
-
Pin Diagram Reset: Resets the input line, when the input is high, all internal registers (including control registers) are cleared, and all IO ports are set to the input mode.
CS: When this input pin is low, that is, CS=0, it means that the chip is selected to allow 8255 to communicate with the CPU; When CS=1, 8255 cannot transmit data to the CPU.
RD: Read the signal line, when this input pin is a low jump edge, that is, when RD generates a low pulse and CS=0, it allows the 8255 to send data or status information to the CPU through the data bus, that is, the CPU reads information or data from the 8255.
WR: Write signal, when this input pin is a low jump edge, i.e. when WR produces a low pulse and CS=0, allowing the CPU to write data or control words to 8255.
D0 D7: Three-state bidirectional data bus, 8255 and CPU data transmission channel, when the CPU executes input and output instructions, through which 8-bit data read and write operations, control words and status information are also transmitted through the data bus.
The 8255 has three independent I/O ports and operates from a single +5V supply, allowing it to operate in three ways.
Method 0 (Basic Input and Output Mode):Mode 1——— strobe input out mode; Mode 2——— bidirectional strobe input and output mode;
PA0 PA7: Port A I/O line, one 8-bit data output latch buffer, one 8-bit data input latch. Works in any of the three ways;
PB0 PB7: Port B I/O line, one 8-bit IO latch, one 8-bit I/O buffer. Cannot work in mode 2;
PC0 PC7: Port C input and output line, one 8-bit data output latch buffer, one 8-bit data input buffer. Port C can be divided into two 4-bit ports by working mode, and each 4-bit port contains a 4-bit latch, which can be used in conjunction with port A and port B, respectively, and can be used as a control signal output or status signal input port.
Doesn't work in way one or two.
A1, A0: Address selection line, used to select the PA port, PB port, PC port and control register of 8255.
When A1=0 and A0=0, the PA port is selected;
When A1=0 and A0=1, the PB port is selected.
When A1=1 and A0=0, the PC port is selected.
When a1=, the control register is selected.
Hello, try the following methods: 1. Abstract asp component has built-in, included with server installation, and more is provided by a third party, today to learn how to use one of the components of file upload aspupload component. >>>More
Zhang Haidi has suffered from severe high paraplegia since she was a child, and has been on the verge of death several times, and her body can be regarded as weak, but for more than 20 years, she has learned 4 foreign languages, translated more than 160,000 words of foreign works, obtained a master's degree in philosophy, and taught herself acupuncture and moxibustion techniques, treating more than 10,000 people for the masses, and has made great contributions. >>>More
Eat, treat, be invited, appreciate face, give face,
On a dog day in 1963, Jiao Yulu took Zhang Mingtang, then deputy director of the Lankao County Party Committee Office, to Wangye Temple in Chengguan Township for investigation. Jiao Yulu asked him to send two taels of food stamps and two dimes to the melon owner. The melon owner said that there is no need to give it if it is worthless. >>>More
Static variables: Variables that exist independently, but are placed under a certain class, and can be used by adding dots to the class name to call the static variable name. And it is a project or program that resides memory directly when it is started and runs into the class. >>>More