I have a pic connected through a RS232 and the transmit seems to be working fine but I am having issues with sending the pic commands(at least its not doing what I want it to).
Code:
:SetTxRx ' Set receive register to receiver enabled
DEFINE HSER_RCSTA 90h
' Set transmit register to transmitter enabled
DEFINE HSER_TXSTA 20h
' Set baud rate
DEFINE HSER_BAUD 2400
' Set SPBRG directly (normally set by HSER_BAUD)
DEFINE HSER_SPBRG 25
' Use only if even parity desired
'DEFINE HSER_EVEN 1
:SendOnline
HSEROUT ["I am online.", 10, 13]
:Online
High Porta.6
:Listen
HSerin [INC]
HSerout ["You entered: ", INC, 10, 13]
IF INC = 1 THEN Think
IF INC = 2 THEN TURNON
IF INC = 3 THEN TURNOFF
GOTO Listen
:TURNON
HIGH Porta.7
GOTO Listen
:TURNOFF
LOW Porta.7
GOTO Listen
When the pic powers up, I get the "I am online." message.
When I send a 1 the pic responds properly with the "You entered: 1" back.
Same with 2 and whatever number I send.
The issue is that It is not running the IF commands.
I also want to make the incoming data a bit longer such as A123. When I try that, I get:
You entered: A
You entered: 1
You entered: 2
and so on.
Any help would be great.
Bookmarks