Have spent several interesting but largely fruitless hours trying to make some progress with the program.
However if I jump passed the COUNTER / WDT routine the TX & RX work fine which is good to know.
Here's the code for it:
One thought does occur to me though, at the start of the program the PIC is placed into SLEEP mode, only to be woken on INTERRUPT.Code:COUNTER=0 ' clear before entry WHILE COUNTER <= 2 ' 4.608sec Loop time (Loop for 30 mins = 781) INTCON.0 = 0 ' Clear int on change flag @ SLEEP @ NOP CLEARWDT COUNTER=COUNTER+1
Code below.
However, GPIO.4 must be pressed and held down (simulating night time) which causes the wake up from SLEEP interrupt, the program then moves down to the COUNTER / WDT loop. I think I might have found a problem here though. For the COUNTER / WDT loop to work and give a 4.6sec test delay the PIC must go into SLEEP mode, if GPIO.4 is continually held down simulating night time and hence causing an INTERRUPT from SLEEP (continually, even resetting the interrupt won't help as button continually pressed) then my thinking says the COUNTER /WDT loop will never work because the PIC is always being woken up.Code:IF GPIO.3= 1 AND GPIO.4= 1 THEN ' Nothing has happened so SLEEP E_OUT=0 ' Disable transmitter INTCON.0 = 0 ' No Inputs detected or it's still light so clear int on change flag @ SLEEP ' and start snoozin..zzzzzzzzzzz indefinatly @ NOP ' Do nothing for 1st instruction on wake-up CLEARWDT ELSE 'IF GPIO.3=0 THEN GOSUB COUNTS 'Bird detected at box - GOTO LABEL COUNTS IF GPIO.4=0 THEN encode 'DARK 'Encode 'DARK 'It's got dark? or just cloudy - GOTO LABEL DARK
A bit garbled I know, sorry, but am I onto something.
Dave




Bookmarks