Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

sending new line to hyperterminal?

Status
Not open for further replies.

bjerkely

Member level 4
Joined
May 26, 2004
Messages
72
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Location
Turkiye
Activity points
589
hyperterminal newline

I'm trying to send New Line character to Hyperterminal using AT89S52 ; but it doesn't work.
What's the matter with the code below?
;010 012 00A 00001010 LF (Line Feed)


mov A,#10
mov SBUF,A

Thanks in advance
 

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,942
Helped
2,309
Reputation
4,620
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,432
hyperterminal carriage return line feed

There is nothing wrong with this code, although I would send CR (carriage return), too .. This will place CARRIAGE at the beginning of the next line ..

Just make sure that both: the PC's serial port and the 89C52's UART are setup with the same parameters: baud rate, data bits, .. etc. and that Rx and Tx lines are crossed over ..

Regards,
IanP
 

silvio

Advanced Member level 3
Joined
Dec 31, 2001
Messages
716
Helped
105
Reputation
210
Reaction score
16
Trophy points
1,298
Location
Romania
Activity points
11,470
hyperterminal new line

bjerkely said:
but it doesn't work.

what's exactly happen on hyperterminal screen ?
 

bjerkely

Member level 4
Joined
May 26, 2004
Messages
72
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Location
Turkiye
Activity points
589
hyperterminal carriage return

There is nothing wrong with the connections and speed.
More specifically I'm trying to see the character string 'HELLO' but I see on the screen HELLO*#;HELLO*#;HELLO*#;

The symbols between HELLOs are not the actual characters that promts but they are some garbage instead of New Line.
 

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,942
Helped
2,309
Reputation
4,620
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,432
how to send a line feed in hyperterminal

Could you post the section of your code that actually sends this:

HELLO
HELLO
HELLO

ASCII string(s) ?

Regards,
IanP
 

bjerkely

Member level 4
Joined
May 26, 2004
Messages
72
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Location
Turkiye
Activity points
589
hyperterminal send cr

Here is my code...
ORG 0000H

MOV TMOD,#20H
MOV TH1,#0FAH
MOV SCON,#50H
ORL PCON,#80H
MOV TCON,#40H

MOV R1,#50H
MOV 50H,#'H'
MOV 51H,#'E'
MOV 52H,#'L'
MOV 53H,#'L'
MOV 54H,#'O'
MOV 55H,#10

;---------------------------------------------------
;Main Program
;---------------------------------------------------
SERIAL:
ACALL char_get

ACALL char_sent
SJMP SERIAL

;---------------------------------------------------
;Character receive subroutine
;---------------------------------------------------
char_get:
JNB RI,char_get
MOV A,SBUF
CLR RI
RET
;---------------------------------------------------
;Character sent subroutine
;---------------------------------------------------

char_sent:
CLR TI
MOV A,@R1
MOV SBUF,A
INC R1
send:
JNB TI,send
CJNE R1,#56H,char_sent
RET

END

Regards
 

silvio

Advanced Member level 3
Joined
Dec 31, 2001
Messages
716
Helped
105
Reputation
210
Reaction score
16
Trophy points
1,298
Location
Romania
Activity points
11,470
new line in hyperterminal

Because you're running in a close loop with infinite calls to char_sent.
And R1 is not initialized each time to 50H when you call char_sent
That's why you send the all contents of IRAM to SBUF.
Since you didn't us any routine to blank your Internal RAM at startup and because after reset IRAM has random values, you see garbage on hyperterminal.

It's nice to use some counter and stop transmision after few HELLO sent. Otherwise after changing your code you'll see HELLO without garbage but scrolling on hyperterminal screen.
 

    bjerkely

    Points: 2
    Helpful Answer Positive Rating

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,942
Helped
2,309
Reputation
4,620
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,432
new line hyperterminal

Try the attached code ..
There are really minor changes, such as added CR character, 7-byte counter based on R0, and, if you want to see "HELLO" for more times you will need to press 'c' ..
The last addition just shows you that the 'char_get' is working too ..

Code:
	ORG	 0000H 

	MOV 	TMOD, #20h
	MOV 	SCON, #52h
	MOV	 PCON, #80h
	MOV 	TH1, #0FAh
	MOV 	TCON, #40h	; SETB TR1

	MOV 	50h, #'H'
	MOV 	51h, #'E'
	MOV 	52h, #'L'
	MOV 	53h, #'L'
	MOV 	54h, #'O'
	MOV 	55h, #10		; LF 
	MOV 	56h, #13		; CR
;-------------------------------------------------
;Main Program 
;-------------------------------------------------

SERIAL:	
	LCALL 	send_string
Not_Continue:
	LCALL 	char_get
	CJNE	A, #'c', Not_Continue

	SJMP	SERIAL

;-------------------------------------------------
;Character sent subroutine 
;-------------------------------------------------

send_string: 
	MOV	R0, #07h		; Loop counter ..
	MOV	R1, #50h

S_Loop:
	MOV 	A, @R1 
	LCALL	Ser_Out
	INC	 R1
	DJNZ	R0, S_Loop
	RET

Ser_Out:
	JNB	TI, $
	CLR	TI
	MOV	SBUF, A
	RET
 
;-------------------------------------------------
;Character receive subroutine 
;-------------------------------------------------

char_get: 
	JNB 	RI, char_get
	CLR	RI
	MOV 	A, SBUF
	RET

; --------------------------------------------------

	END

Regards,
IanP
 

bjerkely

Member level 4
Joined
May 26, 2004
Messages
72
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Location
Turkiye
Activity points
589
how to send a new line charactor in hyperterminal

IanP and silvio, I thank you for your useful advices.In the light of your remarks I 've rearranged my code and it's working now or at least it does what I intended it to...

here is the last form:
org 0000H
MOV TMOD,#20H
MOV TH1,#0FAH

;---------------------------------------------------
;Serial port configuration
;---------------------------------------------------

MOV SCON,#50H
ORL PCON,#80H
MOV TCON,#40H

MOV 50H,#'H'
MOV 51H,#'E'
MOV 52H,#'L'
MOV 53H,#'L'
MOV 54H,#'O'
MOV 55H,#13
;---------------------------------------------------
;Main Program
;---------------------------------------------------
SERIAL:
MOV R1,#50H
ACALL char_get
MOV @R0,A
ACALL char_sent
SJMP SERIAL

;---------------------------------------------------
;Character receive subroutine
;---------------------------------------------------
char_get:
JNB RI,char_get
MOV A,SBUF
CLR RI
RET
;---------------------------------------------------
;Character sent subroutine
;---------------------------------------------------

char_sent:
CLR TI
MOV A,@R1
MOV SBUF,A
INC R1

send:
JNB TI,send
CJNE R1,#56H,char_sent
RET
END
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top