PDA

View Full Version : Input on 12F629



BGreen
- 14th March 2005, 00:41
I'm trying to work a circuit where on interupt I read GPIO.1 to see if an external voltage is present, then go thru some stuff if it is, or if not, go back to a sleep routine. I can get it all to work EXCEPT for reading GPIO.1. I have never used an input and its kicking me. Any help would be appriciated.

'************************************************* ***************
'* Name : detect W/ D-N-for melab *
'* Author : WMG *
'* Notice : *
'* : *
'* Date : 03/13/05 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
@ DEVICE pic12F629, INTRC_OSC_NOCLKOUT ; System Clock Options
@ DEVICE pic12F629, WDT_ON ; Watchdog Timer
@ DEVICE pic12F629, PWRT_ON ; Power-On Timer
@ DEVICE pic12F629, MCLR_OFF ; Master Clear Options (Internal)
@ DEVICE pic12F629, BOD_OFF ; Brown-Out Detect
@ DEVICE pic12F629, CPD_ON ; Data Memory Code Protect
@ DEVICE pic12F629, PROTECT_OFF
;
; Set Variables and aliases as needed.
SYMBOL CAMPOW = GPIO.0
SYMBOL volt = GPIO.1
INPUT volt
WPU = 255
;
; Set External interrupt (GPIO.2) with falling edge trigger...
OPTION_REG = %00001000 ; Enable pullups, falling edge trigger on GP.2, etc
CMCON = %00000111 ; Comparators OFF
INTCON = %10000000 ; Set GIE - clear interrupt enable bit and flags.
;
;
LOW CAMPOW
GOTO BASE ; Skip past interrupt handler
;
; Interrrupt handler
MYINT:
INTCON = %10000000 ; clear interrupt enable bit and flags
; Camera Shutter & Power control and 2 min delay
IF volt = 0 THEN
RESUME BASE
ENDIF
HIGH CAMPOW 'PRESS POWER
PAUSE 20000 'HOLD POWER FOR 20 SECOND
LOW CAMPOW 'RELEASE POWER
RESUME BASE ; resume at BASE section
;

; Main program
BASE:
INTCON = %10010000 ; Set/re-set interrupt enable bit - clear flags
;
LOOP:
ON INTERRUPT GOTO MYINT
SLEEP 900 'SLEEP FOR 15 MIN
GOTO LOOP

Archilochus
- 14th March 2005, 03:09
Hey Butch,
I've never used the "SYMBOL" instruction, so don't have any idea if this could be a problem or not, but I read this in the PBP manual:

"SYMBOL provides yet another method for aliasing variables and
constants. It is included for BS1 compatibility.
>> SYMBOL cannot be used to create a variable. Use VAR to create a variable."

Maybe try this instead:

; Set Variables and aliases as needed.
CAMPOW VAR GPIO.0
volt VAR GPIO.1


Arch

BGreen
- 14th March 2005, 03:46
Thanks Arch,but it actually works. Steveo helped me out, was a stinking pull up.

Archilochus
- 14th March 2005, 14:14
Thanks Arch,but it actually works. Steveo helped me out, was a stinking pull up.

Hi Butch,
Just curious about this - it looks like your code has the internal pullups turned on. Did you need an additional external pullup on the '629, or was it a pullup added somewhere else in the circuit?

Arch

BGreen
- 16th March 2005, 11:14
It was the internal pull up and I didn't have the TRISIO registers set up.