Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/19/03 02:01
Read: times


 
#43736 - Full program to Send data to PC
Responding to: ???'s previous message
This will send a character string via the serial port to any Terminal emulation program like the Hyper Terminla in Windows.

====================================


; Tested OK with 89c51RD2 kit running with 12Mhz crystal.
; Just configure COM2 port in hyperterminal for 4800/8/N/1 and set it to Auto Detect.
; Works with all types of terminal emulation in Hyper Terminal. Only in ViewData type there is
; some extra characters at the end. But still message can be read.
; For a different Buad rate just alter the V24SPD value.


V24SPD EQU 256-26

ORG 0000H

V24SET: MOV PCON, #80H
MOV TMOD, #22H
MOV TH1, #V24SPD
MOV TL1, #V24SPD
SETB TCON.6
MOV SCON, #052H

;MOV 8EH, #02 ; For Ext Ram access with 89c51RD2
;------------------------------------------------------

MAIN: MOV R7, #5 ; To print message 5 times
NEXT: MOV DPTR, #MSG
LCALL STXT
LCALL CRLF
MOV R4, #10
MOV R5, #255
MOV R6, #255
DLYLUP: DJNZ R5, $
MOV R5, #255
DJNZ R6, DLYLUP
MOV R6, #255
DJNZ R4, DLYLUP
DJNZ R7, NEXT

SJMP $
;-------------------------------------------------------

STXT: NOP ; send text from program store at DPTR
MOV A, #0 ; destroy ACC and DPTR
MOVC A, @A+DPTR
JZ ETXT
LCALL SEND
INC DPTR
SJMP STXT
ETXT: RET


BLANK: MOV A, #' ' ; send BLANK
SJMP SEND

CRLF: MOV A, #13 ; send a Carriage Return + Line Feed
LCALL SEND
MOV A, #10
LCALL SEND
RET


SEND: JNB SCON.1, $ ; wait for previous character to go..
CLR SCON.1
MOV SBUF, A
RET

GETCHR: NOP
GETC1: JNB SCON.0, GETC1
CLR SCON.0
MOV A, SBUF
RET

BYTE: PUSH ACC ; send BYTE hexadecimal , destroy ACC only
SWAP A
LCALL NIBBLE
POP ACC
NIBBLE: ANL A, #0FH
ADD A, #246
JC HEXOUT
ADD A, #58
SJMP SEND
HEXOUT: ADD A, #65
SJMP SEND


MSG: DB 'This is Serial link test , 4800, N, 1'

END

List of 3 messages in thread
TopicAuthorDate
Please help me INTERRUPTS            01/01/70 00:00      
   RE: Please help me INTERRUPTS            01/01/70 00:00      
   Full program to Send data to PC            01/01/70 00:00      

Back to Subject List