	
;THIS PROGRAM IS TRYING TO SENT A PACKET OF 25 BYTES TO A FINGERPRINT MODULE IN ORDER TO CONNECT WITH IT.

ORG	000H

;===================================baudrate==========================================

	MOV	SCON,#50H		; receive enable, 8-BIT, 1 STOP BIT.
	MOV	TMOD,#20H		; timer 1 in 8-bit auto reload.
	MOV	TH1,#0FDH		; baud rate 9600.
	SETB	TR1			; Start Timer 1
	ANL	PCON, #01111111B	; SMOD = 0
;======================================================================================

;=======================send the characters from the table to serial port==============	
	MOV	R0,#25                  ;move the number 25 to R0 in order to take the 25 bytes from the table.
	MOV	DPTR,#TABLE             ;Load the destination address to data pointer
NEXT:
	MOV	A,#0                    ;sent zero to ACC
	MOVC	A,@A+DPTR               ;this command takes the first char from table
	MOV	SBUF,A                  ;sent this char to serial port
	JNB	TI,$			;Pause until the TI bit is set.
	CLR 	TI    			;Clear the TI bit before send another character
	INC	DPTR                    ;increase data pointer in order to take the next char
	DJNZ	R0,NEXT                 ;decrease R0 and if not equal to zero jump to NEXT label
;======================================================================================

	MOV	R2,#25                  ;move the number 25 to R0 in order to take the 25 bytes from the serial port.
NEXT1:
	JNB 	RI,$  			;Wait for 8051 to set the RI flag.
	CLR 	RI		        ;Clear the RI bit after in order to receive first byte from serial port
	MOV 	A,SBUF			;Read the character from the serial port.
	MOV	P2,A                    ;sent the char to P2 where is a 7 segment display
	CALL	DELAY                   ;call delay 0.5 second
	DJNZ	R2,NEXT1                ;decrease R2 and if not equal to zero jump to NEXT1 label

;==============================
; DELAY 0.5S
;==============================
DELAY:
	MOV	R5,#5
DL2:
	MOV	R6,#200
DL1:
	MOV	R7,#249
	DJNZ	R7,$
	DJNZ	R6,DL1
	DJNZ	R5,DL2
	RET
	
;=========================================the table of 25 bytes========================================
TABLE:	DB	7EH,00H,00H,00H,1AH,00H,00H,00H,01H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,1BH
	END