Serial communication between two microprocessor kits using 8251.
Aim:
Write a program in ALP to establish Communication between two processors using 8251.
Apparatus:
1. ADS-SDA-86-STA kit 2. 8251 Study card 3. Adapter, Keyboard, Cables, Etc . . .
Procedure:
Transmission
1. Connect 8086 kit PC using RS232 cable. 2. Connect Power supply to 8086 kit and 8251 interfacing kit(only blue( 5v) and black(0v) lines Power cable to power supply) 3. Connect 8251 to 8086 using 50pin and 26pin bus. 4. Short 5 & 6 pins of JP9 in 8251 kit 5. Keep the DIP switch in 1 & 7 on (8086kit), open TALK, and go to options select target device as 8086 and Connect. 6. Change dip switch into 1 & 5on, once reset 8086 kit. 7. Go to file →Download hex file 8. G-4000(on system keyboard), we can observe the output on 8251 kit. 9. Remove RS232 cable from 8086kit and connect it to 8251, transmitted data displayed on PC Monitor
Recieving
1. Connect 8086 kit PC using RS232 cable. 2. Connect Power supply to 8086 kit and 8251 interfacing kit (only blue( 5v) and black(0v) lines Power cable to power supply) 3. Connect 8251 to 8086 using 50pin and 26pin bus. 4. Short 1 & 2 pins of JP9 in 8251 kit 5. Keep the DIP switch in 1 & 7 on (8086kit), open TALK, and go to options select target device as 8086 and Connect. 6. Change dip switch into 1 & 5on, once reset 8086 kit. 7. Go to file →Download hex file 8. Change the DIP switch into 1 & 7 on, once reset. 9. Remove RS232 cable from 8086 kit and connect it to 8251. 10. G-4000 (on 8086 kit keyboard) .enter 11. Give some input from system keyboard (Example press A, B, C, D enter),once reset 8086 kit That data will be received at 8086 kit at location FF00 (press E, enter address FF00 and press Comma you will get the ASCII values of A, B, C,D).
Program:
.OUTPUT 2500AD ;PROGRAM TO TEST 8251 TRANSMISSION CLOCK_FREQ EQU 1536000 ;8253 clock frequency CTL_8251 EQU 3402H ;8251 control port address DATA_8251 EQU 3400H ;8251 data port address TMR1_8253 EQU 3002H ;8253 timer1 address CTL_8253 EQU 3006H ;8253 control port address EXT_RAM_LC EQU 0000:FF00H ;RAM location DBDT EQU F800:4F1FH ;routine for display on data field CNT_BAUD_9600_MODE16 EQU 000AH CNT_BAUD_4000_MODE01 EQU 0140H CNT_BAUD_2400_MODE16 EQU 0028H CNT_BAUD_1200_MODE64 EQU 0014H CNT_BAUD_0300_MODE64 EQU 0050H MODE_WORD16 EQU CEH MODE_WORD1 EQU CDH MODE_WORD64 EQU CFH ;With the count calculated for various baud rates program is ;written to test transmission part of 8251 using RS_232 standard ;Data characters can be sent to 8251 on an interrupt basis.So ;to send characters on interrupt basis the TxRDY pin of the ;8251 is connected to an interrupt input through PIC 8259. ;*************************************** ;PROGRAM TO TEST 8251 TRANSMITTING PART. ;*************************************** DSEG SEGMENT ORG 0 : 3000H MSG DB 'TESTING 8251 IN ASYNCHRONOUS MODE',0DH,0AH,1BH DSEG ENDS CSEG SEGMENT ORG 0000 : 4000H ASSUME CS : CSEG, DS : DSEG START: MOV AX, 00H ;initialisation of stack pointer MOV SS, AX MOV SP, 2000H MOV AX, 00H MOV DS, AX CLI CLD MOV BX, 0202H ;initalisation of interrupt vector PUSH CS POP AX MOV [BX], AX MOV BX, 0200H LEA AX, CS : SRVC1 MOV [BX], AX MOV DX, FFD8H ;ICW1 MOV AL, 13H OUT DX, AL MOV DX, FFDAH ;ICW2(interrupt vector address) MOV AL, 80H OUT DX, AL MOV AL, 0FH OUT DX, AL ;ICW4 MOV AL, 0FEH OUT DX, AL ;OCW1(IR0 mask reset) MOV BX, OFFSET MSG ;BX points to message MOV SI, EXT_RAM_LC ;SI points to RAM locations ;where the characters written to 8251 are stored MOV DX, CTL_8253 ;initialise timer1 in mode2 MOV AL, 76H OUT DX, AL MOV DX, TMR1_8253 MOV AL, < CNT_BAUD_9600_MODE16 ;load the LSB count in OUT DX, AL ;timer1 count reg MOV AL, > CNT_BAUD_9600_MODE16 ;load the MSB count in OUT DX, AL ;timer1 count reg STI ;enable interrupt MOV DX, CTL_8251 ;8251 control port address.Send MOV AL, 00H ;0's to guarantee,device is in OUT DX, AL ;the command instruction format. ;Repeat the same four times NOP NOP NOP NOP OUT DX, AL NOP NOP NOP NOP OUT DX, AL MOV DX, CTL_8251 ;send internal reset command MOV AL, 40H ;to return device to idle state OUT DX, AL NOP NOP NOP NOP MOV DX, CTL_8251 ;load the mode control word MOV AL, MODE_WORD16 OUT DX, AL NOP NOP MOV DX, CTL_8251 ;load the command word MOV AL, 33H ;when CTS* input of 8251 is OUT DX, AL ;asserted low and the 8251 buffer NOP ;is ready for a character,the TxRDY NOP ;pin will go high.Since TxRDY pin ;is connected to the interrupt pin,as soon as TxRDY is set INTR ;is enabled and the process jumps to service routine. BACK: NOP JMP BACK SRVC1: MOV AX, 0000H MOV DS, AX MOV AL, [BX] ;message address stored in reg BX ADD BX, 01H ;read the message byte by byte CMP AL, 1BH ;check if the byte is a last byte JNZ AHEAD MOV BX, OFFSET MSG ;if yes reinitialise the pointer MOV SI, EXT_RAM_LC ;to message and RAM location JMP SRVC1 AHEAD: MOV DX, DATA_8251 ;if not send the char to data port OUT DX, AL ;of 8251 & also save in ram location MOV CL, AL MOV AX, 00H MOV DS, AX MOV AL, CL MOV [SI], AL ADD SI, 01H STI IRET CSEG ENDS END
PROGRAM TO TEST 8251 RECEIVING PART
.OUTPUT 2500AD
CLOCK_FREQ EQU 1536000
CTL_8251 EQU 3402H
DATA_8251 EQU 3400H
TMR1_8253 EQU 3002H
CTL_8253 EQU 3006H
EXT_RAM_LC EQU 0:FF00H
DBDT EQU F800:4F1FH
CNT_BAUD_9600_MODE16 EQU 000AH
CNT_BAUD_4000_MODE01 EQU 0140H
CNT_BAUD_2400_MODE16 EQU 0028H
CNT_BAUD_1200_MODE64 EQU 0014H
CNT_BAUD_0300_MODE64 EQU 0050H
MODE_WORD16 EQU CEH
MODE_WORD1 EQU CDH
MODE_WORD64 EQU CFH
;************************************
;PROGRAM TO TEST 8251 RECEIVING PART.
;************************************
DSEG SEGMENT
ORG 0000 : 3000H
DSEG ENDS
CSEG SEGMENT
ORG 0000 : 4000H
ASSUME CS : CSEG, DS : DSEG
START:
MOV AX, 00H
MOV SS, AX
MOV SP, 2000H
MOV DS, AX
CLI
CLD
MOV BX, 0202H
PUSH CS
POP AX
MOV [BX], AX
MOV BX, 200H
LEA AX, CS : SRVC2
MOV [BX], AX
MOV DX, FFD8H ;ICW1
MOV AL, 13H
OUT DX, AL
MOV DX, FFDAH
MOV AL, 80H
OUT DX, AL
MOV AL, 0FH
OUT DX, AL
MOV AL, 0FEH
OUT DX, AL
MOV BX, EXT_RAM_LC
MOV DX, CTL_8253
MOV AL, 76H
OUT DX, AL
MOV DX, TMR1_8253
MOV AL, <CNT_BAUD_9600_MODE16
OUT DX, AL
MOV AL, >CNT_BAUD_9600_MODE16
OUT DX, AL
STI
MOV DX, CTL_8251
MOV AL, 00H
OUT DX, AL
NOP
NOP
NOP
NOP
OUT DX, AL
NOP
NOP
NOP
NOP
OUT DX, AL
MOV DX, CTL_8251
MOV AL, 40H
OUT DX, AL
NOP
NOP
NOP
NOP
MOV DX, CTL_8251
MOV AL, MODE_WORD16
OUT DX, AL
NOP
NOP
NOP
NOP
MOV DX, CTL_8251
MOV AL, 36H
OUT DX, AL
BACK1: NOP
JMP BACK1
SRVC2:
MOV DX, DATA_8251
IN AL, DX
IN AL, DX
NOP
NOP
NOP
NOP
CMP AL, 0DH
JNZ AHEAD2
MOV AH, 00
MOV SI, AX
CALL FAR DBDT
MOV BX, EXT_RAM_LC
JMP TERM
AHEAD2: MOV [BX], AL
INC BX
TERM: STI
IRET
CSEG ENDS
END
Result:
The Transmission Of 8251 Is Studied And The Output Is Verified

-
UpdatedOct 25, 2014
-
Views10,240
You May Like
Programs for 16 bit arithmetic operations for 8086 (using various addressing modes)
Program for String manipulations for 8086
Program for sorting an array for 8086
Program for searching for a number or character in a string for 8086
Program for digital clock design using 8086.
Programming using arithmetic, logical and bit manipulation instructions of 8051