PDA

View Full Version : Hserout Versus Serout2



bethr
- 20th July 2006, 22:10
Hi all, I have a unexpected fail, porting some code from HSEROUT to SEROUT2
I mean, in my PCB I have a MAX232 with a PIC18f452, using this lines of code working OK :

DEFINE OSC 10
DEFINE HSER_CLROERR 1
DEFINE HSER_RCSTA 90H
DEFINE HSER_TXSTA 24H
DEFINE HSER_SPBRG 64
HSEROUT ["HELLO WORLD",13,10]
(in the hyperterminal appear "HELLO WORLD")

And this Doesn't work in the same board!

DEFINE OSC 10
symbol RXD=PORTC.7
symbol TXD=PORTC.6
TRISC.7=1
TRISC.6=0
TXD=1
SEROUT2 TXD,84,["HELLO WORLD",13,10]
(in the hyperterminal nothing appear!)

I can't figure a mistake.... Can Anyone Helpme?

Darrel Taylor
- 20th July 2006, 22:45
bethr,

Both versions work here. 18F452/MAX232 20mhz.

However, the SEROUT version won't work if you still have either an HSERIN or HSEROUT somewhere in the program. The HSER statement doesn't even need to execute. Simply being in the program is enough. Since you are trying to convert it, it's a possibility.

With any HSER statements in the program, the USART will be initialized on power-up. Which makes it so only the USART can access the TX pin.
<br>

bethr
- 20th July 2006, 22:58
Is right Darrel!,
I start a small program, and this works!, I will do a further search to any instruction using the on chip USART, may be a hserout 'hidden' or a LET statement using some Register related to the serial port...
(but looks strange, I already replace all HSEROUT to SEROUT2 instructions)

bethr
- 20th July 2006, 23:18
is strange that happen,
look, I have my subroutines in another file called "subs.bas", When I compile the main file called "main.bas" I call the subs file, (include "subs.bas"),
compile ok but... doesn't work! (no send data over serial port)

when I compile without (include "subs.bas"), it Works!.
Why? I am confused...

then I comment ALL lines file subs.bas, for ensure that these code doesn't take part of program memory, doing this still doesn't working...

at least I put the two files to form one single, compile it and voila! its working
I don't understand that happen....

keithdoxey
- 20th July 2006, 23:19
(but looks strange, I already replace all HSEROUT to SEROUT2 instructions)

Have you left any DEFINES in there that relate the USART ???

bethr
- 20th July 2006, 23:22
DEFINE OSC 10
symbol RXD=PORTC.7
symbol TXD=PORTC.6
TRISC.7=1
TRISC.6=0
TXD=1
SEROUT2 TXD,84,["HELLO WORLD",13,10]
(in the hyperterminal nothing appear!)



no I sure!..

Darrel Taylor
- 20th July 2006, 23:23
compile ok but... doesn't work! (no send data over serial port)

when I compile without (include "subs.bas"), it Works!.

In the INCLUDE file. Do you jump over the subroutines with a GOTO?

You have to make sure execution doesn't "fall" into a subroutine.
<br>
DT

bethr
- 20th July 2006, 23:43
No I think, because the Hserout version Works OK,

Darrel Taylor
- 20th July 2006, 23:46
Ok, well we can continue playing 20 questions, or...

It might help to see the code.
<br>