What inputs are you getting?
THere are three main problems on your program. :wink:
:arrow: First you set PORTA = %00011 , that meands RA0-RA1 are
inputs and RA2-RA4 are
outputs. When you do:
Code:
PORTA.2 = 0
IF PORTA.2 = 1 THEN
You are writing a 0V to the RA2 pin. That is correct can be done since you defined it as an output. But then you go on and try to read the output you just wrote to. You can write outputs but you can't read them per say.....logically you read inputs and manipulate the outputs.
So no way to tell what the PortA.2 will give you. That is why you aer lucky you are actually getting something.
:arrow: Second little mistake..... You are mixing two commands together. SEROUT2 and SEROUT. The form for SEROUT2 is:
SEROUT2 DataPin{\FlowPin},Mode,{Pace,} {Timeout,Label,}
[Item...]
Where the mode is calculated and a 16780 gives you a 2400 Inverted baud rate.
The SEROUT comand's form is like:
SEROUT Pin,Mode,[Item{,Item...}]
where the Mode is a Fix number you choose from 0-15. For a 2400 inverted baudrate you choose the 4, or since you are including the
modedefs.bas then you can choose the N2400.
What you are doing is mixing them up.... perhaps you meant to use SERIN2
:arrow: The last Little problem is the Inverted part. SInce you are using the MAX232, this chip shifts the voltages for you. Therefore any serial data you want to send must go out in
TRUE mode. Otherwise the data you send will be all wierd like what you are getting. If you connect the PIC straight (no max232) from the pin to the port (thru a 2.2K resistor) then you must send the data inverted, because according to the RS232 protocol a 1 is between -12V and -5V and a 0 is between +5 and +12V.
Let you fix the problem and let me know how it goes.
I hope it helps you some.
Ivancho