??? 04/13/11 16:07 Modified: 04/13/11 16:15 Read: times |
#181858 - Is this code ok ?? Responding to: ???'s previous message |
MOV R0,#25 ;move to R0 the number 25 in order to take 25 bytes NEXT1: CLR A JNB RI,$ ;Wait for 8051 to set the RI flag. MOV A,SBUF ;Read the character from the serial port. CLR RI ;clear Ri flag in order to receive next byte MOV DPTR,#0FE00H ;move to DPTR the address 0FE00H to start storing from this. MOVX @DPTR,A ;store the data of ACC in address which show the DPTR INC DPTR ;increase DPTR in order to store the next byte to the next address DJNZ R0,NEXT1 ;decrease R0 and if not equal with 0 jump to NEXT1 label CALL ECHO ;call ECHO routine ECHO: MOV R0,#25 ;move to R0 the number 25 in order to take 25 bytes MOV DPTR,#0FE00H ;move to DPTR the address 0FE00H to start reading from this. MOVX A,@DPTR ;move the byte which is stored to 0FE00H address to ACC MOV P2,A ;echo this byte to P2 of 8051 which is a led bar CALL DELAY ;call delay in order to see this byte INC DPTR ;increase DPTR in order to store the next byte to the next address DJNZ R0,ECHO ;decrease R0 and if not equal with 0 jump to ECHO label RET |