+ Reply to Thread
Results 1 to 20 of 20
  1. #1
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Pic 12F675... Pulling GPIO.3 Low resets program

    I've been at this for hours... so bare with me please.

    I have a 10k pullup on port 3 (GPIO.3) and set it to input. I have the wiper of a 10k pot connected to GPIO.2 and have it set to analog input. I am not currently using it in the program but plan to, so ADCON0 and ANSEL reflect the planned future use (in case I have something screwed up there). Port 2 is the only analog input port.

    I have an LED and Relay connected to ports 0 and 1 respectively.

    With the program below, an LED and a Relay turn on and turn off every two seconds repeatedly.

    But when I push a button connecting port 3 to ground, all action from the LED and Relay stops (as though I've shorted out the 5v supply). I have checked the supply voltage at the pins of the processor and grounding port 3 has no effect on the supply voltage.

    When the button is released, the LED and Relay return to normal function.

    NOTE: I added the toggling relay just before "Main" to help me understand what was happening. Pushing the button apparently resets the chip because the relay "buzzes" when it is pressed and released.

    Why would bringing input port 3 to ground cause a reset?

    Thank you!

    Ross


    Code:
          Define OSCCAL_1K 1  ' Calibrate internal oscillator
       
       TRISIO = %00111100  ' GPIO.2,3,4 and 5 INPUTS, GPIO.0 and 1 OUTPUTS
       ADCON0 = %10001001  ' Turn on A/D module, Enable AN2, R Justify Result
       ANSEL  = %00100100  ' Fosc /32, Set AN2 analog, the rest digital
       CMCON = 7           ' Analog comparators off
       WPU = %00110000     ' Turn on weak pullups on GPIO.4 and 5
       
       LED VAR GPIO.0
       RELAY var GPIO.1
       I var byte
       
       for i = 1 to 10      'This put in to buzz relay at start of program
       toggle relay      
       pause 50
       next i
       
    Main:   
        HIGH LED        'Turn on LED
        low relay         'Turn on Relay
        pause 2000      
        LOW LED         'Turn off LED
        high relay        'Turn off Relay
        Pause 2000
        goto main        'Do it again...
        end
    Last edited by rossfree; - 24th January 2019 at 21:31.
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    Why would bringing input port 3 to ground cause a reset?
    gp3 pin 4 is the mclr [reset] pin by default , what steps have you taken to configure the pin for a different function ?
    This is more entertaining than Free to Air TV

  3. #3
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    Yep... I see that now. I've been looking for the "define" statement that turns MCLR off. Thank you!
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    I've been looking for the "define" statement that turns MCLR off
    you won't find one

    you need to set the config fuses appropriately ,for pbp3 like this .
    be warned setting gp3 as input can make chip reprogramming difficult for some programmers that cannot control vdd.

    #CONFIG
    cfg = _INTRC_OSC_NOCLKOUT
    cfg&= _WDT_ON
    cfg&= _PWRTE_OFF
    cfg&= _MCLRE_OFF
    cfg&= _BODEN_ON
    cfg&= _CP_OFF
    cfg&= _CPD_OFF
    __CONFIG cfg

    #ENDCONFIG
    This is more entertaining than Free to Air TV

  5. #5
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    I'm still using PBP 2.45

    Can you help with configuration fuses please. Thank you!
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    it would look like this. i don't know how to fit it into that old obsolete system ,you may need to look at or modify the 12f675.inc files




    Code:
    ASM
      __config  _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_OFF & _MCLRE_OFF & _BODEN_ON & _CP_OFF & _CPD_OFF
    ENDASM
    This is more entertaining than Free to Air TV

  7. #7
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    Thank you! I'll give it a try!

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  8. #8
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    This is my updated code. Bringing port 3 low still resets the PIC.

    I tried "_MCLRE_OFF and it did the same. Microcode Studio gives warning (207) that it "Found label after column 1. _MCLR_OFF. With MCLRE it adds: "Duplicate label ("_MCLRE_OFF" or redefining symbol that cannot be redefined)

    This is all gibberish to me and frustrating. I have a hard enough time just writing descent code without spending hours
    (days) getting off he ground. Sorry to complain.

    Help please. Thank you!


    Code:
    ASM
      _MCLR_OFF
    ENDASM
    
       Define OSCCAL_1K 1  ' Calibrate internal oscillator
      
       
       TRISIO = %00111100  ' GPIO.2,3,4 and 5 INPUTS, GPIO.0 and 1 OUTPUTS
       ADCON0 = %10001001  ' Turn on A/D module, Enable AN2, R Justify Result
       ANSEL  = %00100100  ' Fosc /32, Set AN2 analog, the rest digital
       CMCON = 7           ' Analog comparators off
       WPU = %00110000     ' Turn on weak pullups on GPIO.4 and 5
       
       LED VAR GPIO.0
       RELAY var GPIO.1
       I var byte
       
       for i = 1 to 10
       toggle relay 'This put in to buzz relay at start of program
       pause 50
       next i
       
    Main:   
        HIGH LED        'Turn on LED
        low relay       'Turn on Relay
        pause 2000      
        LOW LED         'Turn off LED
        high relay      'Turn off Relay
        Pause 2000
        goto main       'Do it again...
        end
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    Code:
    ASM
      _MCLR_OFF
    ENDASM
    does nothing useful . to write to config registers you need , if you omit any fuses they revert to blank chip value [ that may not suit pbp at all]
    ASM
    __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_OFF & _MCLRE_OFF & _BODEN_ON & _CP_OFF & _CPD_OFF
    ENDASM
    This is more entertaining than Free to Air TV

  10. #10
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    I copied it in exactly as you wrote it. When I try to compile it, it comes up with warnings in Microcode Studio and doesn't produce a HEX file.

    Ross


    Code:
    ASM
    __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_OFF & _MCLRE_OFF & _BODEN_ON & _CP_OFF & _CPD_OFF
    ENDASM
    
       Define OSCCAL_1K 1  ' Calibrate internal oscillator
      
       
       TRISIO = %00111100  ' GPIO.2,3,4 and 5 INPUTS, GPIO.0 and 1 OUTPUTS
       ADCON0 = %10001001  ' Turn on A/D module, Enable AN2, R Justify Result
       ANSEL  = %00100100  ' Fosc /32, Set AN2 analog, the rest digital
       CMCON = 7           ' Analog comparators off
       WPU = %00110000     ' Turn on weak pullups on GPIO.4 and 5
       
       LED VAR GPIO.0
       RELAY var GPIO.1
       I var byte
       
       for i = 1 to 10
       toggle relay 'This put in to buzz relay at start of program
       pause 50
       next i
       
    Main:   
        HIGH LED        'Turn on LED
        low relay       'Turn on Relay
        pause 2000      
        LOW LED         'Turn off LED
        high relay      'Turn off Relay
        Pause 2000
        goto main       'Do it again...
        end
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  11. #11
    Join Date
    May 2013
    Location
    australia
    Posts
    1,716

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    Code:
    Code:
    ASM
    space__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_OFF & _MCLRE_OFF & _BODEN_ON & _CP_OFF & _CPD_OFF
    ENDASM
    you need a space before __config

    what error
    This is more entertaining than Free to Air TV

  12. #12
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,259

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    On that old version, when setting the config bits from within your code you need to comment out the default ones from the device specific .in file or you'll get [ASM ERROR] Overwriting previous address contents

    IMHO the easier handling of config bits alone is worth the upgrade cost.

    /Henrik.

  13. #13
    Join Date
    Oct 2009
    Posts
    597

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    In this version of PBP set the config bits in your code using

    Code:
    @ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON
    Then browse to the 12F675.INC file in the PBP folder and comment out the config lines like this (insert a semi-colon as shown)

    Code:
    ;****************************************************************
    ;*  12F675.INC                                                  *
    ;*                                                              *
    ;*  By        : Leonard Zerman, Jeff Schmoyer                   *
    ;*  Notice    : Copyright (c) 2005 microEngineering Labs, Inc.  *
    ;*              All Rights Reserved                             *
    ;*  Date      : 08/31/05                                        *
    ;*  Version   : 2.46a                                           *
    ;*  Notes     :                                                 *
    ;****************************************************************
            NOLIST
        ifdef PM_USED
            LIST
            include 'M12F675.INC'	; PM header
            device  pic12F675, intrc_osc_noclkout, wdt_on, mclr_on, protect_off
            XALL
            NOLIST
        else
            LIST
            LIST p = 12F675, r = dec, w = -302
            INCLUDE "P12F675.INC"	; MPASM  Header
            ; __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
            NOLIST
        endif
            LIST

  14. #14

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    Quote Originally Posted by Scampy View Post
    In this version of PBP set the config bits in your code using

    Code:
    @ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON
    Then browse to the 12F675.INC file in the PBP folder and comment out the config lines like this (insert a semi-colon as shown)

    Code:
    ;****************************************************************
    ;*  12F675.INC                                                  *
    ;*                                                              *
    ;*  By        : Leonard Zerman, Jeff Schmoyer                   *
    ;*  Notice    : Copyright (c) 2005 microEngineering Labs, Inc.  *
    ;*              All Rights Reserved                             *
    ;*  Date      : 08/31/05                                        *
    ;*  Version   : 2.46a                                           *
    ;*  Notes     :                                                 *
    ;****************************************************************
            NOLIST
        ifdef PM_USED
            LIST
            include 'M12F675.INC'	; PM header
            device  pic12F675, intrc_osc_noclkout, wdt_on, mclr_on, protect_off
            XALL
            NOLIST
        else
            LIST
            LIST p = 12F675, r = dec, w = -302
            INCLUDE "P12F675.INC"	; MPASM  Header
            ; __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
            NOLIST
        endif
            LIST
    Or simpler yet, browse to the 12F675.INC file in the PBP folder and change the config lines like this

    Code:
    ;****************************************************************
    ;*  12F675.INC                                                  *
    ;*                                                              *
    ;*  By        : Leonard Zerman, Jeff Schmoyer                   *
    ;*  Notice    : Copyright (c) 2005 microEngineering Labs, Inc.  *
    ;*              All Rights Reserved                             *
    ;*  Date      : 08/31/05                                        *
    ;*  Version   : 2.46a                                           *
    ;*  Notes     :                                                 *
    ;****************************************************************
            NOLIST
        ifdef PM_USED
            LIST
            include 'M12F675.INC'	; PM header
            device  pic12F675, intrc_osc_noclkout, wdt_on, mclr_off, protect_off
            XALL
            NOLIST
        else
            LIST
            LIST p = 12F675, r = dec, w = -302
            INCLUDE "P12F675.INC"	; MPASM  Header
           __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
            NOLIST
        endif
            LIST
    Just remember you did it so you can put it back for another project.

  15. #15
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    First... thank you for your replies and support! I really have appreciated it!

    I changed the 12F675.inc file as suggested. Still no joy until I realized that MPLAB was overwriting my config. I turned that off and it started working! Yay! MCLR was no longer resetting my PIC.

    and then...Now, when I try to program the chip, I've started getting a slew of program memory errors on MPLAB. I don't know what started this. Could my PIC be bad? I've bounced it back and forth so many times between my circuit board and the Picstart Plus I suppose it could have bit the dust. Somewhere in all my crap, I think I have one more '675. I will look.

    I tried shutting down MPLAB, unplugging the programmer and restarting my computer. No joy.

    I'll dive into the hunt for another '675. If you have any suggestions I would appreciate your thoughts on this new issue.

    Thanks again!!!

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  16. #16
    Join Date
    Oct 2009
    Posts
    597

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    Quote Originally Posted by rossfree View Post

    I changed the 12F675.inc file as suggested. Still no joy until I realized that MPLAB was overwriting my config.
    Ross
    Which method did you use. My suggestion of commenting it out and then including the config settings in the PBP code, or Charlie's suggestion of changing the INC file to read MCLR_OFF ?
    Last edited by Scampy; - 26th January 2019 at 01:16.

  17. #17
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    I changed the include file to say MCLRE_OFF. Between that and setting the configuration bits in MPLAB, it took care of it.

    Thanks for the help!!!

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  18. #18
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    I changed the include file to say MCLRE_OFF. Between that and setting the configuration bits in MPLAB, it took care of it.

    Thanks for the help!!!

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

  19. #19

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    The MCLR pin is used for programming. Once you disable it, programming gets a bit trickier. You need to be sure VPP is powered before VDD, and there is nothing in your circuit to prevent VPP from going above 9 or 10 volts. A cap on the pin can sometimes cause it to fail because of timing. Try programming with the chip not connected to your circuit. FYI, this is one of the many reasons why most of us don't use that pin unless there is no alternative.

  20. #20
    Join Date
    Oct 2004
    Location
    New Hampshire
    Posts
    116

    Default Re: Pic 12F675... Pulling GPIO.3 Low resets program

    I'm programming the chip off the board on a picstart plus. So disabling MCLR has not been a problem for me.

    Thank you!

    Ross
    Never enough knowledge to be called intelligent but just enough knowledge to be considered dangerous!

    I like that! :-)

Similar Threads

  1. 12f675 GPIO Problem. No output on GPIO.2
    By tasmod in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd June 2014, 15:57
  2. Low Power on 16F1827 or 12F675
    By Ioannis in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th May 2013, 07:17
  3. 12F675 A/D and GPIO sleep interrupt
    By macinug in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th September 2008, 14:39
  4. PIC resets every now and then
    By passion1 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th June 2007, 21:41
  5. Trouble pulling pin Low
    By pdegior in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 9th August 2005, 20:49

Members who have read this thread : 21

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