??? 04/26/11 09:46 Read: times |
#182052 - Here we are again.... Responding to: ???'s previous message |
Hello to everyone, I manage to complete the program for the first instruction !!! (thanks Abhishek)
But it seems that I have another problem, I tried to run the program to dscope simulator and I see that the baud-rate is not right. I suspect that goes wrong to the real operation. I run the program and goes to FALSE route after sending and receiving the bytes. Do you have any idea ?? This is the code: ORG 000H CALL BAUDRATE MOV R0,#25 MOV DPTR,#TABLE NEXT: MOV A,#0 MOVC A,@A+DPTR CLR TI ;Clear TI. MOV SBUF,A MOV P2,099H JNB TI,$ ;Pause until the TI bit is set. INC DPTR DJNZ R0,NEXT CALL BAUDRATE MOV R2,#25 MOV DPTR,#RESPONSE NEXT1: JNB RI,$ ;Wait for 8051 to set the RI flag. MOV A,SBUF ;Read the character from the serial port. CLR RI MOV R0,A MOV A,#0 MOVC A,@A+DPTR XRL A,R0 JNZ FAILED DJNZ R2,NEXT1 MOV P2,#0 JMP $ FAILED: MOV P2,#01100110B JMP $ ;===================================baudrate========================================== BAUDRATE: MOV SCON,#50H ; receive enable, 8-BIT, 1 STOP BIT. MOV TMOD,#21H ; timer 1 in 8-bit auto reload. MOV TH1,#-3 ; baud rate 9600. SETB TR1 ; Start Timer 1 ANL PCON, #01111111B ; SMOD = 0 RET ;====================================================================================== ;============================== ; 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,01H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,01H RESPONSE: DB 7EH,00H,00H,00H,01H,00H,00H,00H,01H,00H,00H,00H,03H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,00H,05H END |