PDA

View Full Version : How to use RSIN



Tim Solomon
- 6th March 2007, 12:55
I'm having a lot of trouble reading serial input! Can anyone help?
The circuit is receiving input from a computer running Hyperterminal set at 9600,N,8,1. (There's no MAX232 driver chip.) Here's the code -

Device=16F877
XTAL=20

Declare SERIAL_BAUD = 9600
Declare RSIN_PIN = PORTA.0
Declare RSIN_MODE = 0
Declare RSIN_TIMEOUT = 10000

Dim Serdata As Byte
TRISD=%00000000 'Just to prove the computer has started
PORTD=%00000100 'turn on an LED
Print "Waiting..."
DelayMS 1000
Start:
Serdata=RSIn,{TO_ERROR}
Print HEX Serdata, "*"
GoTo Start
TO_ERROR:
Print Cls, "Timed Out"
Stop

The program produces the following result on power-up:
With RSIN MODE set to 1, (which I think is right) I get "Waiting", 1 second delay, 0*0*0*0*0*.......... but never any input characters.
With RSIN MODE set to 0, I get "Waiting", 11 second delay, "Timed Out"

The signal on pin 2 of the 16F877 is roughly -
+5v __ __ __

-0.5v _______ __ __ ___________

I have tried an 18F4550 with same result. I must be missing something important here!

HenrikOlsson
- 6th March 2007, 13:09
Hi Tim,
I'd love to be able to help you but I think you are in the wrong forum. I don't know which compiler you're using but this forum is for the Micro Engineering Labs PIC Basic Compilers (Standard and PRO).

Sorry....
/Henrik Olsson.

mister_e
- 6th March 2007, 16:36
This is PROTON PDS. As usual, the PORTA have some multiplexed analog stuff on PORTA that MUST be disable first.

ADCON1=7
or
ALL_DIGITAL = TRUE

should do the trick. Also, you should set your config fuses. something like


REMINDERS=FALSE
Config LVP_OFF, HS_OSC, WDT_OFF

The right forum for you will be www.picbasic.org/forum

Tim Solomon
- 7th March 2007, 00:48
Thanks for your feedback. I'll try the Proton PIC Basic Development Forum.
But I'll also take on board your advice, thanks Steve.

Tim Solomon
- 7th March 2007, 01:10
Many thanks, Steve. ADCON1=7 did the trick!

mister_e
- 7th March 2007, 01:14
Good! it's just weird that it's worked even without MAX232 and in TRUE mode.. but anyways.

enjoy!