I'm trying to write some code for a receiver which really was just going to be a timing loop - the sender unit sends time and an on or off, the receiver then should start counting down the time if the sender has told it to run - so I was going to do a timeout and a small timing loop outside of the SERIN command - however it seems the timeout isn't working - prolly due to the fact the input from the RF module is constantly sending noise down the line.
I think my only other way is to interupt out using a timer - but not realy sure how to do it and I have a bit of a phobia about interupts - have done quite a bit of searching on here but still find it a bit of a struggle to understand what everything means -
Does anyone know a simple way I can do what I'm trying to achieve?
Thanks
@ DEVICE PIC16F676, INTRC_OSC_NOCLKOUT, MCLR_OFF, PROTECT_OFF, BOD_ON, CPD_OFF
Define OSCCAL_1K 1
DEFINE OSC 4
TRISA = %001000
TRISC = %000000
ANSEL = 0 'disable analog
T1CON = %00000100
VRCON = 0 ' A/D Voltage reference disabled
CMCON = 7 'Disable comparitor
timesw var PortA.5
gosw var PortA.3
stopsw var PortA.4
timeset var byte
display var byte
'time var word
b0 var byte
b1 var bit
b2 var byte
clear
timeset = 1
PortA = 0
PortC = 0
Begin: 'start sequence
display = (1 << b0) - 1
PORTC = display
pause 100
if b0 < 7 then
b0 = b0 + 1
goto begin
Else
Pause 1000
b0 = 0
portC = b0
Endif
Start:
serin PORTA.3,0,100,time,["READY"],timeset,b1 'Read receiver
gosub disply
time:
b2 = b2 + 1
if b2 > 200 and timeset > 0 and b1 = 1 then
timeset = timeset - 1
b2 = 0
endif
if timeset = 0 then b1 = 0
goto start
disply:
display = (1 << timeset) 'Set display to be bar type
PORTC = display 'output LEDs
PORTA.0 = b1
return
Bookmarks