| ??? 10/17/09 08:18 Read: times |
#169834 - Problem in transmitting 16 bit serially |
Hello,
i am facing problem in trasmitting 16 bits through 8052 to pc. i have made two different programs to solve the problem but couldnt do it. The main program through which i got the idea.
ORG 000H
JMP MAIN
ORG 023H
JMP SERIAL
ORG 030H
MAIN:
MOV SCON,#50H
MOV TMOD,#20H
MOV TH1,#-24
SETB TR1
SETB EA
SETB ES
MOV A,#'A'
MOV SBUF,A
JMP $
SERIAL:
JB RI,RECEIVE
CLR TI
INC A
CJNE A,#'Z'+1,SKIP
MOV A,#'A'
SKIP:
MOV SBUF,A
RETI
RECEIVE:
CLR RI
MOV A,SBUF
CPL A
MOV P1,A
RETI
END
This was working correctly and it send character a-z to the pc. The first program that i made increaments the DPTR register and sends its increamented output to the pc as a 16 bits i used the idea of sending DPL as lower 8 bits and DPH at upper 8 bits.
ORG 000H
JMP MAIN
ORG 023H
JMP SERIAL
ORG 030H
MAIN:
MOV SCON,#50H
MOV TMOD,#20H
MOV TH1,#-24
SETB TR1
SETB EA
SETB ES
MOV R1,#01
MOV DPTR,#0000H
MOV SBUF,DPH
JMP$
SERIAL:
CLR TI
DJNZ R1,SKIP
MOV R1,#02
MOV SBUF,DPL
INC DPTR
RETI
JMP$
SKIP:
MOV SBUF,DPH
RETI
END
It worked correctly but when using the same program to send the two 8 bits i couldnt got the desired result.
ORG 000H
JMP MAIN
ORG 023H
JMP SERIAL
ORG 030H
MOV DPTR,#0000H
MAIN:
INC DPTR
MOV SCON,#50H
MOV TMOD,#20H
MOV TH1,#-24
SETB TR1
SETB EA
SETB ES
MOV A,#00
MOV SBUF,'B'
JZ $
MOV TMOD,#00
CLR TR1
CLR EA
CLR ES
JMP$
SERIAL:
CLR TI
MOV A,#01
MOV SBUF,'C'
RETI
SKIP:
MOV SBUF,DPH
RETI
FINISH: RETI
END
Thanks |
| Topic | Author | Date |
| Problem in transmitting 16 bit serially | 01/01/70 00:00 | |
Duplicate Thread! | 01/01/70 00:00 |



