PDA

View Full Version : HyperTerminal



Tomas
- 1st March 2004, 18:28
Hi everyone,

I downloaded the code below and run it, i was expecting to see the msg "Hello World" but nothnig came up. I'm not sure if the problem is with my PIC16F877 running with 4MHz or HyperTerminal.
I think the PIC is sending the data, as the LED connected to TX (pin 25, PORTC.6) is falshing continously. However the receive pin of the DB-9 connecter (pin 2) is HIGH all the time and don't know what that means.
HyperTerminal is set to 9600- 8-N- 1
I'm just wondering if i'm supposed to see the output on the Terminal? And if not how can i test/ see the result?

Cheers,
Tom


Define LOADER_USED 1

Include "modedefs.bas" ' Mode definitions for Serout


loop: Serout2 PORTC.6,16468,["Hello",10,13] ' Display "Hello", next line
Pause 500 ' Wait .5 second

Serout2 PORTC.6,16468,["World",10,13,10,13] ' Display "World", skip a line
Pause 500 ' Wait .5 second

Goto loop ' Do it forever
End

NavMicroSystems
- 1st March 2004, 18:52
Hi Tom,

you don't need to include "modedefs.bas"
(it does neither help nor hinder)

Mode 16468 ($4054) means 9600 8N1 driven inverted.

This mode is ok if you connect PORTC.6 of the PIC directly to the RX Pin (Pin 2) of the DB9 connector
(no RS232 driver)


I think the problem is caused by the LED you have connected to that Pin, the LED is drawing too much power from the PIC output.

The PC-COM-Port is expecting RS232 levels (+/- 10V)
most COM-Ports work with TTL-levels from a PIC when connected directly to the PIC.

Tomas
- 1st March 2004, 19:28
Hi,
I have tried it as you mentioned. I just ignored my MAX232 and connected PORTC.6 direct to pin 2 of the DB-9 connecter. The result was the same (no data has shown). The LEDs were disconnected.
I think the problem might be with the HyperTerminal, not sure how to use it, do u think it is enough to just specife the boudmode and wait the msg to show up? How about the modem protocols and all those settings?

Cheers,
Tom

NavMicroSystems
- 1st March 2004, 19:41
If you are using an RS232 driver (i.e. MAX232) you need to use a different mode (TRUE instead of inverted)

For 9600 8N1 this would be 84 ($54)

What is your clock speed ? 9600 Baud won't work with a 4MHz Crystal.

Try 4800 Baud Mode $40BC (inverted) $00BC (true)

rgds

languer
- 1st March 2004, 20:32
Thomas,

No expert here, but you probably want a current limiting resistor between the PIC output (C6) and the PC. Otherwise the PIC is trying to pull-down the 'iddle' level (which I believe to be +12V) to ground (not a good idea). The manual (PBP) suggests 1k in series, I have used this with many other PICs before and it has worked with no problems. SEROUT2 assumes 4MHz clock, which is what you're using, so you should have no problem there. Is the C6 output an open-drain, or analog type (I do not have the datasheet available). If so, you have to use either a pullup or define it as a digital IO (whichever the case may be).

Good luck,

languer.

Tomas
- 1st March 2004, 23:25
Hi again,

Have tried with 4800 Baud, behavs a bit different as the LEDs connected to PORTC.6 and pin 2 of the DB-9 connecter fashes (the LEDs were connected for only test purpose). The thing is i still cann't see the output.
Can't tell where the fault is (PIC16F877 -> MAX232-> DB-9) com3 is used.
What am i missing? Please help

Thanks,
Tom.

NavMicroSystems
- 2nd March 2004, 00:29
Hi Tom,

what crystal are you using ?

have you DEFINEd it ?
(important for correct baud-rate generation)

DEFINE OSC 8 ' for 8 MHz crystal

connecting the PIC via MAX232 to your PC is actually the right way.

Then you need to Set a "TRUE" Mode because the MAX232 does the inversion for you.

Here some MODEs:

300 Inverted $4CF1 True $0CF1
1200 Inverted $432D True $032D
2400 Inverted $418C True $018C
4800 Inverted $40BC True $00BC
9600 Inverted $4054 True $0054


If you see nothing at all in your hyperterm window do the following tests:

1. Hyterterm, COM-Port, Serial Cable

put a jumper between Pin 2 & Pin 3 of the COM-Port you are intend to use for the communication (connect RX & TX)
Start Hyperterm, and type something on your keyboard.
you should see the characters you typed in your hyperterm window.
If you have enabled the "LOCAL ECHO" option in Hyperterm every character you typed should appear twice, with LOCAL ECHO OFF only once.
(Disconnect the Jumper and see the difference)

If this is OK you can be sure your Hyterterm, COM-Port and Serial Cable is OK.

2. MAX232

a TTL-HIGH Level (+5V) on one of the MAX232 TTL Inputs should give - 10 to 12V on the corresponding RS232 output

a TTL-LOW Level (0V) on one of the MAX232 TTL Inputs should give + 10 to 12V on the corresponding RS232 output

have you connected GND to Pin 5 of the DB9 Connector ?