??? 04/05/11 07:03 Read: times |
#181691 - Intel 8051 RS-232 Interface and fingerprint module !! |
Hello there
I want your help about this program. I have a device that I must sent one packet which consists of 25 bytes via serial interface (rs-232) using 8051 micro-controller and after the package received form the device it responds with another packet (25 bytes). For example I must sent something like this: 7E 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 (25 bytes) and after that I must receive something like this: 7E 00 00 00 01 00 00 00 01 00 00 00 0A 00 00 00 00 00 00 00 00 00 00 00 0C I wrote this program and now I want to see the packet that the device sent to host (8051). But I can't see it complete, I only receive the first and the last byte, this is the program, is it anything wrong ? Thank you in advance :) 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 ;====================================================================================== MOV R0,#25 MOV DPTR,#TABLE NEXT: MOV A,#0 MOVC A,@A+DPTR CLR TI ;Clear TI. MOV SBUF,A ;Send the content of ACC to Serial port JNB TI,$ ;Pause until the TI bit is set. INC DPTR DJNZ R0,NEXT MOV R2,#25 NEXT1: JNB RI,$ ;Wait for 8051 to set the RI flag. MOV A,SBUF ;Read the character from the serial port. MOV P2,A ;Echo the content of ACC to P2 CALL DELAY CLR RI ;Set the RI=0 for getting the next byte DJNZ R2,NEXT1 ;============================== ; DELAY 0.5S ;============================== DELAY: MOV R5,#5 DL2: MOV R6,#200 DL1: MOV R7,#249 DJNZ R7,$ DJNZ R6,DL1 DJNZ R5,DL2 RET ;============================== TABLE: DB 7EH,00H,00H,00H,33H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,1AH,00H,00H,00H,00H,00H,00H,00H,4EH END |