Input on 12F629


Closed Thread
Results 1 to 5 of 5

Thread: Input on 12F629

  1. #1
    Join Date
    Oct 2004
    Location
    Fayetteville Arkansas
    Posts
    44

    Default Input on 12F629

    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

  2. #2
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    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

  3. #3
    Join Date
    Oct 2004
    Location
    Fayetteville Arkansas
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    Thanks Arch,but it actually works. Steveo helped me out, was a stinking pull up.

  4. #4
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BGreen
    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

  5. #5
    Join Date
    Oct 2004
    Location
    Fayetteville Arkansas
    Posts
    44


    Did you find this post helpful? Yes | No

    Default

    It was the internal pull up and I didn't have the TRISIO registers set up.

Similar Threads

  1. Input problems with 12F629?
    By achilles03 in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 24th April 2018, 06:25
  2. Sony LanC Program
    By l_gaminde in forum Code Examples
    Replies: 2
    Last Post: - 25th September 2009, 18:51
  3. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 01:50
  4. Using LEDs as light sensors
    By skimask in forum Code Examples
    Replies: 3
    Last Post: - 30th December 2006, 22:19
  5. Using GPIO.3 as input on 12F629
    By Sharky in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th May 2006, 19:41

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts