12F683 GPIO.3 problem


Closed Thread
Results 1 to 8 of 8
  1. #1

    Question 12F683 GPIO.3 problem

    Hi all:

    I am pulling out what little hair I have left on this.
    Such a simple program segment, that I cannot get to work using GPIO.3 as an input.

    I simply want to turn on a test LED connected to GPIO.4 for a short time (PAUSE 2000), after GPIO.3 is momentarily pulled low, and then turn it off, and loop till GPIO.3 is momentarily pulled low again. This is only to confirm whether this module is working or not.

    It works fine with other GPIO's set up as inputs / outputs, but when I try to use GPIO.3 as the input, it does the following:

    The test LED instantly comes on, and stays on, until GPIO.3 is pulled low, it will then turn off and stay off out as long as GPIO.3 is pulled low. (I have a 10K pull-up on GPIO.3 , probably do not need it but it's there.)

    I have searched the forum, read Melanies thread on fuse configs, etc , but must be missing something very basic.

    The simple program segment is below:

    ANSEL = %00000000
    CMCON0 = 7
    CMCON1 = 7
    ADCON0 = %00000000
    INTCON = 0
    define OSC 8
    @DeviceMCLR_OFF
    TRISIO = %101000

    Main:

    GPIO.4 = 0
    IF GPIO.3 = 1 THEN Main
    GPIO.4 = 1 'TEST LED IS TURNED ON HERE
    PAUSE 2000
    GPIO.4 = 0 'TEST LED IS TURNED OFF HERE
    GOTO Main

    For test purposes I have nothing else connected to the PIC.

    As you can see, I have the TRIS register configured to also use GPIO.5 as an output rather than .3 , which does indeed work fine.
    Can someone please enlighten me?

    Thanks

    Ken

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    1 = INPUT
    0 = OUTPUT

    take another look at you TRIS.
    Dave
    Always wear safety glasses while programming.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Thanks for pointing that out - however - that did not solve the problem. If I read the data sheet correctly, it does not matter anyway how the TRIS is configured for GPIO.3 , 'cause it always defaults to input only.

    Ken

  4. #4
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default

    Try putting:
    @ DEVICE PIC12F683, MCLR_OFF

    at the very top of you program
    Louie

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Louie:

    THANK YOU THANK YOU

    I knew the answer would be found from one of the great contributors to this group.

    I thought that the MCLR business might have had something to do with it, but your simple answer fixed it.

    Thanks again

    Ken

  6. #6
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default

    Cool!!
    Happy to contribute
    Louie

  7. #7
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default

    What programmer are you using...

    I use the PICKIT2... and this exact thing drove me NUTS!! about a week ago... finally while reading the docs for the 12f683 (something you MUST get used to doing) I came across the "configuration" register and realized this is what people call setting the "fuses"... this configuration register can only be set on initial programming. I found it right on the main screen of the pickit2 program, look for the "configuration" link just under the "Help" dropdown. It is an 12 bit register and bit 5 controls that mclr/gpio.3 pin.

    I have not figured out exactly how to set each of these bits in my program... yet. So I do it manually each time I burn the chip.

    This is one of the (in my opinion) very frustrating aspects of learning to work with these amazing PIC's.

    I did not realize this register was VERY DIFFERENT than the other registers like ANSEL, CMCON0... etc. Different in that it can only be setup on initial programming and can not be changed by the program.

    Hope this helps... Keep studying those .pdf docs.

    Dwight

    PS. This is my first post on this forum
    Last edited by Heckler; - 30th October 2009 at 05:34.

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Heckler View Post
    What programmer are you using...

    I use the PICKIT2... and this exact thing drove me NUTS!! about a week ago... finally while reading the docs for the 12f683 (something you MUST get used to doing) I came across the "configuration" register and realized this is what people call setting the "fuses"... this configuration register can only be set on initial programming. I found it right on the main screen of the pickit2 program, look for the "configuration" link just under the "Help" dropdown. It is an 12 bit register and bit 5 controls that mclr/gpio.3 pin.

    I have not figured out exactly how to set each of these bits in my program... yet. So I do it manually each time I burn the chip.

    This is one of the (in my opinion) very frustrating aspects of learning to work with these amazing PIC's.

    I did not realize this register was VERY DIFFERENT than the other registers like ANSEL, CMCON0... etc. Different in that it can only be setup on initial programming and can not be changed by the program.

    Hope this helps... Keep studying those .pdf docs.

    Dwight

    PS. This is my first post on this forum
    http://www.picbasic.co.uk/forum/showthread.php?t=11116
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Problem with ASM IRQ using FSR0 on PIC18F252
    By mytekcontrols in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 11th March 2008, 20:48
  2. 10F206 Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd August 2007, 18:49
  3. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  4. Hardware problem or what ?
    By Steve S. in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 4th March 2007, 21:39
  5. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59

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