I have two pics: pic16f88 and pic16f688. The f88 is running a loop that sends a message whenever a button is pressed. I have also tried this in a timed loop where it sends every second instead of when a button is pressed.
DEFINE osc 8
osccon.4 = 1:osccon.5 = 1:osccon.6=1
ANSEL = 0
pinout var PORTB.1
LED VAR PORTB.0 ' Assign name "LED" to PORTB.0
btn var PORTA.0
TRISA.0 = 1
myloop:
if (not(btn)) then
High LED ' Turn on LED connected to PORTB.0
Serout2 pinout,396,["PBPSUX"]
endif
Low LED ' Turn off LED connected to PORTB.0
Goto myloop
End
And my second pic, the f688, is supposed to be waiting for the message and turn an led on if it receives anything.
DEFINE osc 8
osccon.4 = 1:osccon.5 = 1:osccon.6=1
ANSEL = 0
pinin var PORTA.1
LED VAR PORTA.0 ' Assign name "LED" to PORTB.0
test var byte[5]
low LED
myloop:
Pause 500 ' Delay for .5 seconds to allow the other pic to start sending.
low LED
Serin2 pinin,396,[wait("P"),str test\5]
if (test) then
goto lighton
endif
pause 500
high LED
Goto myloop
lighton:
high LED
goto lighton
End
If the second pic receives nothing it is supposed to start waiting again.
For some reason the first pic works find because it is blinking and we can see the noise using an oscilloscope from the serial. However the second pic never turns its light on.
Can anyone see what I might be doing wrong?
Your LED is defined wrong, so even if the chip does receive it wont actually light. Are you sure it's supposed to be PORTA.0 and not PORTB.0 like the other device?