Tim Solomon
- 6th March 2007, 11: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!
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!