PDA

View Full Version : need help with "hello world" in hyperterm



ericmiles
- 31st October 2007, 05:57
Hello everybody,

Just getting started with microcontrollers and serial communication, and looking for some advice to diagnose my problem.

I have a pic 18F4520 connected through a DB9 serial cable, through a keyspan USB/serial adapter.

I'm trying to get "Hello world", or "Finally working" to print to the screen of hyperterminal.

my code:

'TX is connected to pin C6; switch is connected to pin B0

switchVar var byte
input portb.0


Main:
SwitchVar = portb.0
if switchvar=1 then
Serout2 portc.6,16468,["Hello World",10,13]
endif
goto main


I have the settings in hyperterm at 9600,8-N-1.

my lovely output in hyperterm is the following:

€øxøøøøøøø€øxøøø€øøø€øxx€øxøøøøøøø€øxøøø€øøø€øxx€ø xøøøøøøø€øxøøø€øøø€øxx


I've tried many different options, slower baud rates, putting resistors in/out of the transmit line, sending DEC through serout2 .. . .

Everytime I hit the switch, I get the string of garbage above (albeit consistently the same garbage which I guess is good). When I tried the above options, I get different garbage on the hyperterm, but it is always consistent garbage.

From looking around on the net, my best guess is that Hyperterminal is receiving binary through the serial port, as people have said that this results in garbage. Not sure how I'm doing it, or if this is even the case.

Any help appreciated.

eric

HenrikOlsson
- 31st October 2007, 06:47
Hi,
You don't say if you're using a MAX232-type-of-circuit but have you tried:

Serout2 portc.6,84,["Hello World",10,13]

Make sure you use a X-tal or resonator for the osciallator as the internal oscillator may not be acurate enough.

/Henrik Olsson.

ericmiles
- 31st October 2007, 14:09
Hi,
You don't say if you're using a MAX232-type-of-circuit but have you tried:

Serout2 portc.6,84,["Hello World",10,13]

Make sure you use a X-tal or resonator for the osciallator as the internal oscillator may not be acurate enough.

/Henrik Olsson.

Thanks for the response:

I'm not using a MAX232 device. Tried your the code, with the different logic->spits out different garbage. I am using a 4 Mhz x-tal external that has worked for me with this chip for several other non-serial comm applications. Though I've read that I can't use a 9600 baud rate with this x-tal, I've also tried the same code with different mode #s for 4800 (see below), and run it at 4800 baud in hyper term. It gives me the EXACT same garbage!

switchVar var byte
input portb.0


Main:
SwitchVar = portb.0
if switchvar=1 then
Serout2 portc.6,188,["Hello World A",10,13]
pause 500
Serout2 portc.6,16572,["Hello World B",10,13]
endif
goto main

still hopeful,
eric

ericmiles
- 31st October 2007, 15:08
Thanks for the help.

first time on the forum.

My code/wiring were correct. But I switched from XT->HS for programming my PIC. It works perfectly now. The tip that the problem could be the oscillator was the tip to put my trouble shooting in the right direction.

eric