Russ Kincaid
- 26th March 2009, 01:44
I have use this configuration before with no problem, I don't know what is wrong. GPIO.0 never goes high.
REM DEVICE = 12F675
CMCON = 7 'SETS DIGITAL MODE
ANSEL = 0 'GPIO.0 TO GPIO.3 SET AS DIGITAL
OPTION_REG = 0 'WEAK PULLUPS ENABLED
TRISIO = %00001100 'GPIO.2 AND GPIO.3 SET AS INPUT
VRCON.7 = 0 'TURN OFF VOLTAGE REFERENCE
' ************************************************** ***************
'CONDITIONS: INTERNAL OSC CLOCK OUT, WDT DISABLED, PWR UP TIMER DISABLED,
'MCLR FUNCTION: INPUT PIN, BROWN OUT RESET DISABLED, NO PROTECTION
DEFINE OSCCAL_1K 1 'SAVES OSCILLATOR CALIBRATION
START:
HIGH GPIO.0
PAUSE 100
LOW GPIO.0
PAUSE 100
IF NOT GPIO.2 AND NOT GPIO.3 THEN START 'IF BOTH ARE LOW, THEN LOOP
LOW GPIO.0
PAUSE 500
IF GPIO.2 OR GPIO.3 THEN HIGH GPIO.0 'ENERGIZE RELAY
IF NOT GPIO.2 AND NOT GPIO.3 THEN DELAY
GOTO START
DELAY:
PAUSE 2000 '2 SECONDS
LOW GPIO.0 'DE-ENERGIZE RELAY
GOTO START
END
REM DEVICE = 12F675
CMCON = 7 'SETS DIGITAL MODE
ANSEL = 0 'GPIO.0 TO GPIO.3 SET AS DIGITAL
OPTION_REG = 0 'WEAK PULLUPS ENABLED
TRISIO = %00001100 'GPIO.2 AND GPIO.3 SET AS INPUT
VRCON.7 = 0 'TURN OFF VOLTAGE REFERENCE
' ************************************************** ***************
'CONDITIONS: INTERNAL OSC CLOCK OUT, WDT DISABLED, PWR UP TIMER DISABLED,
'MCLR FUNCTION: INPUT PIN, BROWN OUT RESET DISABLED, NO PROTECTION
DEFINE OSCCAL_1K 1 'SAVES OSCILLATOR CALIBRATION
START:
HIGH GPIO.0
PAUSE 100
LOW GPIO.0
PAUSE 100
IF NOT GPIO.2 AND NOT GPIO.3 THEN START 'IF BOTH ARE LOW, THEN LOOP
LOW GPIO.0
PAUSE 500
IF GPIO.2 OR GPIO.3 THEN HIGH GPIO.0 'ENERGIZE RELAY
IF NOT GPIO.2 AND NOT GPIO.3 THEN DELAY
GOTO START
DELAY:
PAUSE 2000 '2 SECONDS
LOW GPIO.0 'DE-ENERGIZE RELAY
GOTO START
END