PIC12F683 pin GP3 as output


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

    Default PIC12F683 pin GP3 as output

    Hello folks,
    before I tried play with picbasic I worked with PICAXE. I have done few projects with PICAXE 08M2 which is a rebranded PIC12F683 with bootloader.
    In PICAXE is one simple cheat which allows to use the pin3 (MCLRE) as output. Pin3 drives an NPN transistor via manipulating weak pullup resistor. In attachment find the schematis which I use wery often. It works fine all the time.
    For example here is a simple led blinking code in PICAXE looks like:
    Code:
    #picaxe 08m2
    do
    pullup $08    ;pullup on GPIO.3 LED ON
    pause 500
    disable          ;disable pullups LED OFF
    pause 500
    loop
    Name:  GPIO3_output.png
Views: 2239
Size:  345.8 KB

    Now the question is how do they made it? I try similar on PIC12F683 in picbasic but no success.
    Try to led blinking code in picbasic like:
    Code:
    ;PIC12F683
    
    TRISIO=0
    ANSEL=0
    OPTION_REG.7=1   ;enable WPU
    
    strt:
    wpu=%00001000      ;enable WPU on GPIO.3
    pause 500
    wpu=%00000000      ;disable WPU on GPIO.3
    pause 500
    goto strt
    end
    OK, I now this is not work. I also now the GPIO.3 WPU is activatable only via
    MCLRE, the GP3 pull-up is enabled when MCLRE is set to"1" in the configuration word register, and disabled when MCLRE is set to"0".

    How It works in PICAXE, thats the question. Does anyone have an idea?

    Louis

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default Re: PIC12F683 pin GP3 as output

    can you post also the fuse configuration?

    Ioannis

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: PIC12F683 pin GP3 as output

    Hello,

    in PICAXE no need to use any config.

    In picbasic I use this:

    Code:
    #CONFIG
    __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
    #ENDCONFIG
    But I also used this:

    Code:
    #CONFIG
    __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_ON & _CP_OFF
    #ENDCONFIG

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default Re: PIC12F683 pin GP3 as output

    The weak pullup on GP3 is enabled only when MCLR is enabled.

    You may try also ANSEL to set it to

    DO
    ANSEL=0
    PAUSE 500
    ANSEL.3=1
    PAUSE 500
    LOOP

    This will enable and disable the weak pullup.

    Ioannis

  5. #5
    Join Date
    Oct 2011
    Posts
    54


    Did you find this post helpful? Yes | No

    Default Re: PIC12F683 pin GP3 as output

    Try setting GP3 to input as setting to output turns off weak pull-ups

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: PIC12F683 pin GP3 as output

    Quote Originally Posted by Ioannis View Post
    The weak pullup on GP3 is enabled only when MCLR is enabled.

    You may try also ANSEL to set it to

    DO
    ANSEL=0
    PAUSE 500
    ANSEL.3=1
    PAUSE 500
    LOOP

    This will enable and disable the weak pullup.

    Ioannis
    tried, not working. ANSEL.3 is for pin GP4 not for GP3.

  7. #7


    Did you find this post helpful? Yes | No

    Default Re: PIC12F683 pin GP3 as output

    GP3 is setupable only as input.

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default Re: PIC12F683 pin GP3 as output

    OK, then this would only work if one could change the MCLR bit in config word, address 2007h.

    But this can only be accessed in Programming the chip...

    Interesting one!

    Ioannis

  9. #9
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: PIC12F683 pin GP3 as output

    GP.3 is only configurable as an added input pin when nor being used as the RESET pin. NO output configuration is possible.
    Dave Purola,
    N8NTA
    EN82fn

  10. #10


    Did you find this post helpful? Yes | No

    Default Re: PIC12F683 pin GP3 as output

    yes, if I configure the MCLR bit in config word to "1" then the LED is ON because the transistor is open via internal pull-up. If I configute the MCLR bit to "0" then internal pull-up is disabled and the transistor is closed because the 1M resistor is pull the base to ground.
    That's work, but how to do that in program I don't know. However, it must work somehow, because in PICAXE environment it works.

  11. #11
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: PIC12F683 pin GP3 as output

    how sure are you that a picaxe 8m2 is a 12f683

    this makes me doubtful a 12f683 pegs out at 20mhz
    Attached Images Attached Images  
    Warning I'm not a teacher

  12. #12


    Did you find this post helpful? Yes | No

    Default Re: PIC12F683 pin GP3 as output

    Quote Originally Posted by richard View Post
    how sure are you that a picaxe 8m2 is a 12f683

    this makes me doubtful a 12f683 pegs out at 20mhz
    That's a good question, PICAXE webpage shows this:
    http://www.picaxe.com/What-is-PICAXE/Superseded-Parts/
    But after better research, I think all my 08M2 devices are PIC12F1840 and thats makes more sens.
    http://www.picaxe.com/What-is-PICAXE...E-Chip-Labels/
    After look in to the datasheet, on this chip is possible to control the pullups via special function register WPUA. This chip allows to separately control each WPU's include the pullup on pin GP3.
    In this case is possible with this trick use the GP3 as digital output.

    I have an idea, the picaxe has a built in security option, when someone try to read the firmware, the bootloader is "self erasing" and the chip is no more work as picaxe, but still works like an ordinary PIC.
    Tomorrow I try read it, and I will after that know what kind PIC is it.
    Last edited by louislouis; - 10th February 2018 at 23:53.

  13. #13


    Did you find this post helpful? Yes | No

    Default Re: PIC12F683 pin GP3 as output

    Hello,
    finally success. I grab one of my PICAXE 08M2, read it with pickit programmer (destroy the bootloader) and yes, it is a PIC12F1840 not a 12F683 which is a previous version of PICAXE 08M (Richard has good suggestion).

    OK, back to my question if it is possible to use the GP3 (MCLR) pin as digital output on this 12F1840 yes, it is!
    This method is suitable to switch simple devices like relays, LEDs, etc. The state is only 1 or 0 (on/off).
    All done with enabling or disabling the GP3 pin internal pull-up resistor. The circuit is the same as in my previous post, and the example code for PIC12F1840 LED blinking on GP3 is like:
    Code:
    ;PIC 12F1840
    #CONFIG
      __config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_ON
      __config _CONFIG2, _WRT_OFF & _PLLEN_ON & _STVREN_ON & _BORV_19 & _LVP_OFF
    #ENDCONFIG
    
    DEFINE OSC 32    ; Use internal clock 
    OSCCON = %01110000
    CLKRCON = 0
    
    TRISA = %000000
    ANSELA = 0  
    OPTION_REG.7=0  ; Enable internal pull-ups
    
    strt:
    wpua=%001000
    PAUSE 500
    wpua=%000000
    PAUSE 500
    goto strt
    The LED is on when pull-up is set ON, and the LED is OFF when the pull-up is set to OFF, that simple it is.

    I think, this method is usable for all PIC devices which allows to individual pull-up switching on MCLR pin.
    Last edited by louislouis; - 11th February 2018 at 10:47.

  14. #14
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: PIC12F683 pin GP3 as output

    As a point of reference:


    PICAXE Chip Type Label on Chip (DIP) Label on Chip (SM) Advanced Technical Details
    PICAXE-08M2 PICAXE-08M2+ 12F1840 Microchip Datasheet
    PICAXE-14M2 PICAXE-14M2 PIC16F1825 Microchip Datasheet
    PICAXE-18M2 PICAXE-18M2+ PIC16F1847 Microchip Datasheet
    PICAXE-20M2 PICAXE-20M2 PIC16F1829 Microchip Datasheet
    PICAXE-20X2 PIC18F14K22 PIC18F14K22 Microchip Datasheet
    PICAXE-28X2 PIC18F25K22 PIC18F25K22 Microchip Datasheet
    PICAXE-40X2 PIC18F45K22 PIC18F45K22 Microchip Datasheet
    Dave Purola,
    N8NTA
    EN82fn

  15. #15
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: PIC12F683 pin GP3 as output

    Louislouis, that was some impressive "thinking outside the box". Well done!

Similar Threads

  1. Question on using MCLR pin for interupt. (PIC12F683)
    By g-hoot in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th February 2009, 02:15
  2. Turn on output pin
    By savnik in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th March 2007, 11:49
  3. Input / output using same pin
    By leonel in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th March 2007, 21:19
  4. using TOCK pin as output?
    By droptail in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th November 2006, 17:15
  5. How to set analog pin to output 5V?
    By james in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 8th July 2004, 07:24

Members who have read this thread : 3

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