8251a has several port addresses _ 8251a initialization and process

8251a internal structure diagram

The 8251A is a programmable universal synchronous/asynchronous receiver/transmitter. It is usually used as a serial communication interface and is widely used in microcomputers with the Intel80X86 CPU.

8251a has several port addresses _ 8251a initialization and process
8251a has several port addresses

The 8251a has two consecutive port addresses. The data input port and the data output port share the same even address, while the status port and the control port share the same odd address.

8251A initialization programming process and program
8251a has several port addresses _ 8251a initialization and process

Example: 8251A works in asynchronous mode. The mode selection control word is 11111011B and the work command control word is 00010001B. The initialization procedure is:

...

MOV AL, 0FBH ; 8251A mode selection

OUT CONTR,AL

MOV AL, 11H ; 8251A operation command word

OUT CONTR,AL

...

Application Example 8251A

Example: Hardware connection and software programming for two-machine serial communication between two microcomputers in a microcomputer system.

(1) Requirements

Serial communication between the two A and B computers, A machine to send, B machine to receive. It is required that the application developed on the A-machine (whose length is 2DH) be sent to B. The two parties use start-stop asynchronous mode. The data format of the communication is 8 characters, 2 stop bits, a baud rate factor of 64, no parity, and a baud rate of 4800. The CPU and the 8251A exchange data by query. The port address assignment of the 8251A is: 309H is the command/status port, and 308H is the data port.

(2) Analysis

Because it is a short-distance transmission, it is not necessary to set a MODEM. The two microcomputers can directly connect through the RS-232 standard interface. At the same time, the query I/O method is adopted. Therefore, in the receiving/sending program, it is only necessary to check whether the status of the send/receive ready status is set or not, and l bytes can be transmitted and received.

(3) Design

1 hardware connection

Based on the above analysis, both microcomputers are treated as DTEs (Data Terminal Equipment), and communications can be performed using the simplest transmission lines TxD, RxD, and GND. Using 8251A as the main chip of the interface and then configure a small number of additional circuits, such as the baud rate generator, RS-232C and TTL level conversion circuit, address decoding circuit, etc. can constitute a serial communication interface.

8251a has several port addresses _ 8251a initialization and process

2 software programming

It can be seen from the question that the receiving and sending programs should be written separately. Each program section includes the 8251A initialization, status query, and input/output sections. When the receiver/sender's 8251A is initialized, it is first necessary to determine the mode for selecting the control word and the work command control word. According to the requirements in the question, there are:

The sender's mode selection control word is 11001111B=CFH, and the work command control word is 00111110B=37H.

The receiver's mode selection control word is 11001111B=CFH, and the work command control word is 00010100B=14H.

Sender's sender (omit STACK and DATA segments)

CSEG SEGMENT

ASSUME CS: CSEG

TRA PROC FAR

START: MOV DX,309H ; Control port

MOV AL. 00H ; Empty operation

OUT DX,AL

MOV AL,40H ; Internal Reset

OUT DX,AL

NOP

MOV AL,0CFH ;Mode word (asynchronous, 2 stop bits, 8 characters, no parity, baud rate factor 64)

OUT DX, AL

MOV AL, 37H ; Command word (RTS, ER, RxE, DTR, and TxEN are all set to 1)

OUT DX, AL

MOV CX,2DH ; Bytes transmitted

MOV SI, 300H; Send Area First Address

L1: MOV DX,309H ; Status port

IN AL, DX; Check status bit D. (TxRDY)=1?

TEST AL, 38H; Check Error

JNZ ERR ;Error handling

AND AL,01H

JZ L1 ; Waiting to send if not ready

MOV DX,308H ;Data port

MOV AL,[SI] ;Send ready for sending, send 1 byte from send area

OUT DX, AL

INC SI ; Modify memory address

DEC CX ; number of bytes minus 1

JNZ L1 ; Not sent out, continue

ERR: (slightly)

MOV AX, 4C00H ; Sent out, back to DOS

INT 21H

TRA ENDP

CSEG ENDS

END START

Receiver receiving program (omit STACK and DATA segments)

SCEG SEGMENT

ASSUME CS:REC

REC PROC FAR

BEGIN: MOV DX,309H ; Control port

MOV AL, 0AAH ; Empty operation

OUT DX, AL

MOV AL,50H ; Internal Reset

OUT DX, AL

NOP MOV AL,0CFH ;mode word

OUT DX, AL

MOV AL, 14H ; Command word (ER, RxE set to 1)

OUT DX, AL

MOV CX,2DH ; Bytes transmitted

MOV DI, 400H; receiving area first address

L2: MOV DX,309H ; Status port

IN AL, DX; Status Bit D2 (RxRDY) = 17

TEST AL, 38H; Check Error

JNZ ERR ; Turn error handling.

AND AL, 02H

JZ L2 ; Receive not ready, wait

MOV DX,308H ;Data port

IN AL, DX ; Receive ready, receive 1 byte

MOV [DI], AL ; Save to receive area

INC DI ; modify memory

LOOP L2 ; Not completed, continue

ERR: (slightly)

MOV AX,4C00H ;Has been received, the program ends, exit

INT 21H ; Return to DOS

REC ENDP

CSEG ENDS

END BEGIN


Moving head beam light

Well and hight quality control
New design products
Customers design and Logo are welcomed
Quickily delivery
Competitive prices
Fit for gifts and premiums
sample can be available
OEM acceptable
Years of exporting experience as professional stage lighting manufacturer:
Senior R&D technical staff with 7 years experience in stage lighting industry;
Strict quality control in producing to maintain reliable quality;
Provide cost-effective products, wholesale price;
Professional sales team to provide perfect service.



Our company have 13 years experience of LED Display and Stage Lights , our company mainly produce Indoor Rental LED Display, Outdoor Rental LED Display, Transparent LED Display,Indoor Fixed Indoor LED Display, Outdoor Fixed LED Display, Poster LED Display , Dance LED Display ... In additional, we also produce stage lights, such as beam lights Series, moving head lights Series, LED Par Light Series and son on...

Moving Head Light Series,Beam Moving Heads Light,Beam Moving Light,Moving Head Light Beam

Guangzhou Chengwen Photoelectric Technology co.,ltd , https://www.cwledpanel.com