Q: using MCLR for Input on 12F683


Closed Thread
Results 1 to 40 of 47

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default From the start

    You can set it up for an input from the beginning of the program then still use it later for programming. Just make sure your circuit will still allow the Vpp signal to control it during programming otherwise it will boop at you and report an error.
    Louie

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


    Did you find this post helpful? Yes | No

    Default

    And make sure you circuit will handle the programming voltage.

    I like to use some method of isolation when programming. The simplest is a two pin header with a jumper clip.
    Dave
    Always wear safety glasses while programming.

  3. #3


    Did you find this post helpful? Yes | No

    Default 2-pin header

    Makes sense, thanks guys - I had planned on input circuit isolation at the pin, but wasn't sure if there was some other issue that I'd run into during subsequent programming...

    Thanks again, and happy new year all!

  4. #4
    Join Date
    Jan 2009
    Posts
    34


    Did you find this post helpful? Yes | No

    Default Help - 12F683 and servo control in Picbasic

    Hi, new to this forum and to PIC's in general. I fly RC and have used a 12F683 to act as failsafe system for 3 servos.

    I've tried the pulsout command but the output just goes HI?? (I have scope to check).

    Here is the code:

    pos var byte ' Define our storage location for the servo position information.
    servo var byte ' Define our storage location for the servo number to move.
    cont var byte ' Define a variable to hold the count.

    ' 4 mhz clock internal
    ' 500 = 1 ms
    ' 1000 = 2 ms
    ' 1250 = 2.5 ms


    pos = 1250

    start:


    for cont = 0 to 50
    pulsout portb.4,pos ' Send servo# ? to position ?.
    pause 20 ' Wait 20 ms.
    next cont ' Next pulse.


    goto start ' Return to get more serial input.


    Can anyone help??

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


    Did you find this post helpful? Yes | No

    Default

    Try changing pos to a WORD size var and see if that helps
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Jan 2009
    Posts
    34


    Did you find this post helpful? Yes | No

    Question

    Quote Originally Posted by mackrackit View Post
    Try changing pos to a WORD size var and see if that helps
    Thanks! it worked on the 16F84A chip.

    I'm still having difficulty with the 12F683 though. The pulsout doesn't seem to work. I wonder if the chip supports that command?

    I've also tried running the servo by setting the pin high and low timing the high between 1 to 2 ms and the low to 20ms. It works, but it won't accept a decimal number.

    at 4 mHz, I need to pause for between .5ms and 2.5ms but it only accepts 1 and 2 !!!

    suggestions??

    John.

    p.s., here's the code:



    posit var word

    cont var word
    cont2 var word
    Q var word


    let posit = 3/2

    Let Q = 25

    start:

    for cont = 1 to 50
    high 0
    pause posit
    low 0
    pause 20
    next cont



    goto start

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


    Did you find this post helpful? Yes | No

    Default

    It doesn't show in your code so I will assume that the device has not been configured to what you want to do with it since it has other features.
    Start by setting the oscillator then the ports with the TRISIO command, found on page 35 of the data sheet, shut OFF the comparators and the A/D feature:
    Code:
    OSCCON = %01100000  ' Ocs set to 4 MHz
    TRISIO = %00000000  ' Set all ports to outputs, in this example
    CMCON0 = 7                ' Analog comparators off
    ANSEL  = 0                ' Analog select set to digital, pg 69 data
    ADCON0 = 0                ' A/D turned OFF, pg 68 of data
    Then use the PAUSES command instead of PAUSE for a better resolution of the timming you need:
    PAUSE 1 gives you 1ms where PAUSES 1000 will do the same but now you can get your 1.5ms with PAUSES 1500.
    Last edited by LinkMTech; - 3rd January 2009 at 03:49. Reason: Then use GPIO.# not PORT.#
    Louie

  8. #8
    Join Date
    Dec 2005
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by LinkMTech View Post
    You can set it up for an input from the beginning of the program then still use it later for programming. Just make sure your circuit will still allow the Vpp signal to control it during programming otherwise it will boop at you and report an error.
    As a newbie, I was under the impression that the MCLR had to be pulled high when the circuit is powered up, but after reading a little more, I'm not sure. My circuit will have a switch that is either off or on at power up. I'm planning to pull a pin to ground if the switch is on and then I would use internal pull-ups on the pin when it is off. Since I don't program the chips on board, can I use the MCLR pin for the switch, or does it need to be high when the circuit is powered up? That would be awesome if I could free that pin up for use.
    Gary

  9. #9
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    On the 12F683, MCLR can be handled internally by the PIC (see CONFIG options in the PICs Datasheet), thereby freeing that pin for your use. (equally applies to 12F675 and 16F628 since they were mentioned earlier in this thread).

  10. #10
    Join Date
    Dec 2005
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    On the 12F683, MCLR can be handled internally by the PIC (see CONFIG options in the PICs Datasheet), thereby freeing that pin for your use. (equally applies to 12F675 and 16F628 since they were mentioned earlier in this thread).
    Thank you Melanie,
    I looked at the data sheet and see what you are saying. The one thing I'm still not sure about is if the MCLR pin has to be high when the circuit is powered up? If so, then my switch won't work since it may be pulling the pin to ground. This blurb from the PIC Basic Pro manual is what has me confused:

    Make sure the /MCLR pin is connected to 5 volts either through some kind of voltage protected reset circuit or simply with a 4.7K resistor. If you leave the pin unconnected, its level floats around and sometimes the PICmicro MCU will work but usually it won=t. The PICmicro MCU has an on-chip power-on-reset circuit so in general just an external pull-up resistor is adequate.
    Gary

  11. #11
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    If you set the CONFIG for the PIC to handle MCLR internally, then FORGET about MCLR being high or low... it's all handled for you behind the scenes.

    Thereafter the pin (that was formally the MCLR pin) is treated as a regular I/O (except that on some PICs it's INPUT ONLY - check with your PICs Datasheet).

    If you need the pin to be normally HIGH and it's pulled down by your switch, then you need a PULL-UP Resistor (usually connected between the PIC pin concerned and +5V). Some PICs have internal Pull-Ups you can enable either on a pin-by-pin basis, or globally for an enitire Port. Again check with your Datasheet if the pin you want to use has Pull-Up's available on it - not all pins have them.

    If you need the pin to be normally LOW and pulled-up by your switch (not a recommended way of connection - but it will work), then you need a PULL-DOWN Resistor (usually connected between the PIC pin concerned and 0v). You will have to provide one of those yourself externally as the PIC will not provide one internally. Any value between 4K7 and 22K would probably suffice.

  12. #12
    Join Date
    Dec 2005
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    If you set the CONFIG for the PIC to handle MCLR internally, then FORGET about MCLR being high or low... it's all handled for you behind the scenes.

    Thereafter the pin (that was formally the MCLR pin) is treated as a regular I/O (except that on some PICs it's INPUT ONLY - check with your PICs Datasheet).

    If you need the pin to be normally HIGH and it's pulled down by your switch, then you need a PULL-UP Resistor (usually connected between the PIC pin concerned and +5V). Some PICs have internal Pull-Ups you can enable either on a pin-by-pin basis, or globally for an enitire Port. Again check with your Datasheet if the pin you want to use has Pull-Up's available on it - not all pins have them.

    If you need the pin to be normally LOW and pulled-up by your switch (not a recommended way of connection - but it will work), then you need a PULL-DOWN Resistor (usually connected between the PIC pin concerned and 0v). You will have to provide one of those yourself externally as the PIC will not provide one internally. Any value between 4K7 and 22K would probably suffice.
    This is great news! Thank you for explaining it so well.
    Gary

Similar Threads

  1. How to MCLR by code for 16F877
    By fbestepe in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 26th November 2014, 00:51
  2. 12F683 - Pin1 not working
    By ruijc in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th February 2014, 17:38
  3. 16f677a to 12f683
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 25th July 2007, 06:16
  4. What does this MCLR instruction mean?
    By bartman in forum General
    Replies: 16
    Last Post: - 30th November 2004, 00:32
  5. I/O pin and MCLR
    By Dwayne in forum FAQ - Frequently Asked Questions
    Replies: 1
    Last Post: - 15th July 2004, 10:52

Members who have read this thread : 0

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