PDA

View Full Version : Another RS232 question...



Christos_K
- 29th May 2005, 23:33
Hi all! Have being trying to send a message from a PIC16F786 to my PC..Have been using the following schematic that was found from the book of C. Hellebuyck "Programming PIC Microcontrollers with PicBasic".

The code that I have been using is the following:
-------------------------------------------------------------------
include "modedefs.bas"

define osc 10

trisb = %00000010

portb.0 = 1

serout portb.1, t2400, ["hello", 10, 13]

end
--------------------------------------------------------------------

In the seiral communications window of Microcode studio something is received but it is a set of characters rather than "hello"

Is there something wrong with the code?

What about the RS232 Cable connections??

I am using the following configuration in my DB9 connector:

Pins 1,6,4: short-circuit
Pin 2: T2out
Pin3: R2in
Pin 5: Ground
Pins 7,8: Short circuit
Pin9: unused

Would it be better to use the schematic as shown in Help/ICD etc.. of the Microde code studio help and HSEROUT instead? How should I have my DB9 pin configuration in this case?

Darrel Taylor
- 30th May 2005, 03:32
It's not like Chuck to leave things out, hmmmm!

Well, this is what I use for RS232 Comm to PC.
http://www.pbpgroup.com/files/RS232_Cable.jpg
HTH,
   Darrel

Added:
Pin 6 = DSR "Data Set Ready"
Pin 7 = RTS "Request To Send"

Bruce
- 30th May 2005, 15:04
Portb.1 is wired to the max232 TTL output. Portb.2 is wired to the max232
TTL input.

Try: serout portb.2, t2400, ["hello", 10, 13]

Christos_K
- 1st June 2005, 01:56
Have managed to make the circuit work! Another question though..I am using the rs232 port to receive the result from an a/d conversion measuring a potentiometer...is there any clever way instead of getting line after line the results to somehow clear the screen of the terminal so i can get only one message like "DC Voltage: xx" where only the xx value will change ?

mister_e
- 1st June 2005, 05:17
if you have some hability with Visual Basic, you can do a simple terminal program in 10-15 minutes. Use MSComm and in MsComEvent when you receive EOT character (26) clear the text box you use to display your data.