I'm not actually using the serial at the moment, I'm just trying to get to the "other" part of the code, but I'll try 2400 bps, I'll also try the osccal
So you're telling me I should set that bit to 0 in my code?
Nope still no go
This is the code and attached is the schematic
I know the slave is bringing the pins high (multi-meter and beep confirms it)
Edit: One clue I have is.... if I comment out the serial routine and tell it to goto the 'testSlave' label, it works fine
Code:
' Configure the pic
@ device pic12F675, INTRC_OSC_NOCLKOUT, WDT_ON, PWRT_ON, MCLR_OFF, BOD_ON, CPD_OFF, PROTECT_OFF
DEFINE OSCCAL_1K 1
N2400 con 4
CMCON = 7
ANSEL = 0
OPTION_REG.7 = 0
Relay1 VAR GPIO.5
Relay2 VAR GPIO.4
SlavePower VAR GPIO.2
SlaveRelay1 VAR GPIO.0
SlaveRelay2 VAR GPIO.1
Serial VAR GPIO.3
B0 var BYTE
SlaveState VAR BYTE
WhichRelay VAR BYTE
INPUT SlaveRelay1
INPUT SlaveRelay2
INPUT Serial
OUTPUT Relay1
OUTPUT Relay2
OUTPUT SlavePower
LOW Relay1
LOW Relay2
restart:
SlaveState = 0
PAUSEUS 1000
HIGH SlavePower
main:
B0 = 0
SERIN Serial, N2400, 20, testSlave, [1], B0
LOW SlavePower
SELECT CASE B0
CASE 2
GOSUB subUp
CASE 3
GOSUB subDown
CASE 4
GOSUB subStop
END SELECT
GOTO restart
testSlave:
WhichRelay = GPIO & 3
IF SlaveState <> WhichRelay THEN
SlaveState = WhichRelay
SELECT CASE WhichRelay
CASE 0
GOSUB subStop
CASE 1
GOSUB SubUp
Case 2
GOSUB subDown
END SELECT
ENDIF
goto main
subUp:
LOW Relay2
HIGH Relay1
RETURN
subDown:
LOW RELAY1
HIGH Relay2
RETURN
subStop:
LOW Relay1
LOW Relay2
RETURN
Bookmarks