got a bit of a problem, think it could be to do with the timing of the serin serout commands. basically, its a rf switch with seperate rf solutions (UK) transmitter/reciever pair bought from maplin. Im trying to get a light to turn on when a serial command is recieved. it looks like its coming through the reciever ok (as in serial signal looks like its ok- cant be exact though) but the pic is not reading the serial command properley. any ideas??? heres the code.
Send:
cmcon0 = 7
ansel = 0
TRISA = 0
TRISC = 1
PORTA = 0
'RF test program
Start:
IF PORTC.2 = 1 Then
PORTA.0 = 1
PORTA.0 = 0
PORTA.0 = 1
PORTA.0 = 0
PORTA.0 = 1
PORTA.0 = 0
SerOut 0,4,[%10010,%1111]
EndIF
GoTo Start
Recieve:
cmcon0 = 7
ansel = 0
TRISA = 1
TRISC = 0
PORTC = 0
Dat VAR BYTE
'RF test program
Start:
SerIn PORTA.0,4,[10010],Dat
IF Dat = 1111 Then
PORTC.2 = 1
Pause 500
PORTC.2 = 0
EndIF
GoTo Start
By the way, its a PIC 16F684 and the bit in the send program at the start is apparently to tell the transmitter that there is somethgin about to be sent, ie. wake it up. (a tip from microchip forums)
Thanks.
Bookmarks