PIC12F629 w/ Internal Oscillator


Closed Thread
Results 1 to 8 of 8
  1. #1
    RossW's Avatar
    RossW Guest

    Question PIC12F629 w/ Internal Oscillator

    This chip has an internal oscillator (20 Mhz). Here's my question: how do I program this chip with (a) PIC Basic and (b) PIC Basic Pro, and do I need to do anything special in order to drop it into a breadboard with an LED (i.e. the simple blink.bas program). Will the EPIC programmer save the configuration bits each time I erase/program it?

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


    Did you find this post helpful? Yes | No

    Default

    Actually the internal Oscillator is 4MHz...

  3. #3
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Rossw,

    Rossw>>This chip has an internal oscillator (20 Mhz). Here's my question: how do I program this chip with (a) PIC Basic and (b) PIC Basic Pro, and do I need to do anything special in order to drop it into a breadboard with an LED (i.e. the simple blink.bas program). Will the EPIC programmer save the configuration bits each time I erase/program it?<<

    I believe it has up to 20 MHZ capability, and only a 4 mhz internal Osc. Make sure your MCLR pin is set as a input, not reset. <g>. I have ran into this a few times when I forget to reset my programmer.

    Set one of your I/O pins as a output through your TRIS commmand, Turn off all digital, put your diode in, and a small resister in series... program it as you like. It will look something like the follolwing..
    (The following program was done on a 12F675.) Should be somewhat close to what you are looking for...



    ANSEL=0
    CMCON=%00000111
    TRISIO=%00001000

    Loop:
    GPIO.0=1
    Pause 500
    GPIO.0=0
    PAUSE 500
    goto Loop
    end.
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  4. #4
    RossW's Avatar
    RossW Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks for the info, Dwanye.

    Dwanye>>Make sure your MCLR pin is set as a input, not reset. .

    Not sure what that means, being a newbie to microcontrollers and all. Does this mean I hook up this pin to +5V through a resistor?

    Also, I'd eventually like to use 4 other pins for output to LEDs - do I need additional TRISIO commands for that?

  5. #5
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Rossw,


    Dwanye>>Make sure your MCLR pin is set as a input, not reset. .

    Rossw>>Not sure what that means, being a newbie to microcontrollers and all. Does this mean I hook up this pin to +5V through a resistor?<<

    When you use your HEX programmer, you must do a couple of things... Make sure you choose the "INTOSC" (so the chip will use its internal oscillator, and Make sure your HEX programmer is set us as such...

    OSC INTOSC
    WTD Enabled
    PUT Disabled
    BOR Enabled
    MCLR input pin
    Code Not protected
    EEPROM Not protected



    Also, I'd eventually like to use 4 other pins for output to LEDs - do I need additional TRISIO commands for that?

    Yes, teh TRISIO tells the chip to make the pins Input or Output. You need to have output to light up a LED. You must also make sure that the pins *are* output, by checking the Chips documentation. (It will say I/O pin)

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

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


    Did you find this post helpful? Yes | No

    Default

    See the code I posted in answer to the "HPWM Question" Thread. Change the defines to match 16F629 instead of 16F628 and you're in business.

  7. #7
    RossW's Avatar
    RossW Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks, Melanie, for the cross-reference.

    If I set MCLR as input do I still need to connect to +5V through a 4.7k resistor, for example?

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


    Did you find this post helpful? Yes | No

    Default

    I'm now going to reveal the secret of Life, the Universe and Everything here (as far as the PIC's setup Defines are concerned)... just you and me... so follow me to the end on this one...

    There are two possible MCLR defines...

    MCLR_ON
    MCLR_OFF

    MCLR_OFF has the PIC handling the MCLR function internally, allowing you to use pin RA5 as an Input (Big NOTE here... on the PIC16F628/629 it's the only pin in the whole PIC that's INPUT ONLY - so don't design anything expecting to use this pin as an Output - it won't happen - again read the Datasheet).

    MCLR_ON has the PIC expecting you to provide external MCLR circuitry and RA5 is otherwise unavailable to you. Generally, if you are an electronics God (or Godess), you can strap MCLR (if you actually need to use one) directly to Vcc (+5v). If you are a lesser mortal, you can take it through a 4K7 Resistor. If you're totally inept, then you might need a 100nF Capacitor (actual value depending on ones level of incompetence) between MCLR and Vss (0v) as well.

    Now... here's the secret stuff... How do we know what PIC defines I can use?

    Well, open up the PBP directory, and in it you will find an INC subdirectory. Open that up and you'll see a heap of files. Find the Mxxxx.INC file for the PIC you're interested in... in your case you have a PIC16F629 so find the file M16F62X.INC and open it up with something like Notepad. Don't make any changes now, but just have a look at it. It reveals the internal sex life of the PIC. All the Configuration Fuse Defines that you can use from within PBP are listed here at the top, and lower down all the Registers are Listed. If it's not in the list, you can't use it - but trust me, it's usually all there. This list is for use with the PM (default assembler). If you're going to use MPASM, look for the appropriate file (eg P16F628.INC) located in something like the MCHIP_Tools subdirectory - there are some minor differences, like MCLR_ON for PM, is _MCLRE_ON for MPASM.

    Cross-reference the Configuration Fuses with the PIC's Datasheet Section entitled "Special features of the CPU" (section 14 I think for your PIC). If you look down the eleven OSC selections listed in the INC file for example, you'll find them all in the Datasheet (Section 14.1 & 14.2) named appropriately (although some may be known under multiple names like ER_OSC is the same as ER_OSC_NOCLKOUT the little extra being provided by MeLabs for your convenience).

    Finally... writing those defines into your program... it's easiest and cleanest using the default PM Assembler...

    @ DEVICE MCLR_OFF

    or

    @ DEVICE pic16F629, MCLR_OFF

    Both are identical, except if you use the one specifying the PIC, the Compiler will error with a message if you attempt to compile your program for any PIC other than a 16F629. It's actually handly to be reminded by the compiler that you potentially might be compiling for the wrong PIC... for my part it means that I don't spend nights pulling my hair out over silly mistakes and my golden locks are all intact.

    If you need (or prefer) to use the MPASM assembler, you have to string multiple defines on one line, using line extenders when you run off the right-hand margin of your page.

    Example

    @ __config _XT_OSC & _WDT_ON & _LVP_OFF & _MCLRE_ON

    is for MPASM as what's listed below is for PM...

    @ DEVICE XT_OSC
    @ DEVICE WDT_ON
    @ DEVICE LVP_OFF
    @ DEVICE MCLR_ON

    Note the difference between _MCLRE_ON and MCLR_ON (as previously mentioned a couple of paragraphs ago).

    btw... the @ just indicates that you are entering an Assembler instruction or directive.

    Melanie

Similar Threads

  1. Pic16f882 internal oscillator
    By offlander in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th October 2009, 21:15
  2. 18F4431 - internal oscillator and PLL ?
    By AndrewC in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd March 2009, 15:20
  3. Internal oscillator please help
    By timbash in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 26th February 2009, 15:11
  4. PIC18F4620 Using the Internal Oscillator
    By kiwipiper in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd October 2007, 09:07
  5. PIC12F675, accuracy of baud rate with Internal Oscillator
    By Chris Mayhew in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st August 2005, 23: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