Setting up a 12F683 to run at 20 Mhz


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    When you set

    'DEFINE OSC 20'

    You are not "telling" the chip to run at 20MHz, you are telling PBP that
    the chip is running at 20MHz (rather than 4MHz), and to adjust all pertinent
    timing accordingly.

    If the chip is actually running at 4MHz and you have DEFINE OSC 20, all the PBP PAUSES (and a lot of other timing, such as SERIN) will be off by a factor of 5. PBP uses a default define of 4MHz, so if you are actually running at 4MHz, you don't have to change this define. PAUSE 1000 will give a 1 second delay. If the PIC is actually running at 20MHz, then a PAUSE 1000 will give a 200 millisecond delay.
    If you are running at any speed other than 4MHz, then you change the define accordingly.
    Charles Linquist

  2. #2
    Join Date
    Jan 2009
    Posts
    34


    Did you find this post helpful? Yes | No

    Unhappy

    Quote Originally Posted by Charles Linquis View Post
    When you set

    'DEFINE OSC 20'

    You are not "telling" the chip to run at 20MHz, you are telling PBP that
    the chip is running at 20MHz (rather than 4MHz), and to adjust all pertinent
    timing accordingly.

    If the chip is actually running at 4MHz and you have DEFINE OSC 20, all the PBP PAUSES (and a lot of other timing, such as SERIN) will be off by a factor of 5. PBP uses a default define of 4MHz, so if you are actually running at 4MHz, you don't have to change this define. PAUSE 1000 will give a 1 second delay. If the PIC is actually running at 20MHz, then a PAUSE 1000 will give a 200 millisecond delay.
    If you are running at any speed other than 4MHz, then you change the define accordingly.
    Ah, makes sense.

    So in theory, if I use CFG_HS_OSC to get the 12F683 to use the external oscillator on pins 2&3 and use the DEFINE OSC 4 command...then the LED's should blink at the rate of 5X...right?

    If so, I just tried that and the rate is still X???

    What am I doing wrong?

    Better yet...How do I confirm that the chip is running at 20Mhz??

    John.

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Read this link: http://www.picbasic.co.uk/forum/showthread.php?t=543
    Setting the config statement to HS controls the power supplied to the oscillator to "enable" it to run at high speed. The crystal determines that speed, The Define statement as Charles explained Syncs up the chips internal timing to the supplied crystal and Oscon allows you to alter the oscillator's prescaler in code (more or less ).
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Jan 2009
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Read this link: http://www.picbasic.co.uk/forum/showthread.php?t=543
    Setting the config statement to HS controls the power supplied to the oscillator to "enable" it to run at high speed. The crystal determines that speed, The Define statement as Charles explained Syncs up the chips internal timing to the supplied crystal and Oscon allows you to alter the oscillator's prescaler in code (more or less ).
    I'm not sure if you saw the photo I posted above...I'm using 2-27pF capacitors with the crystal. How can I confirm that the chip is running at 20Mhz?

    John.

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Run the program below -

    Set the port to output

    TOPP:
    Toggle LED
    PAUSE 1000
    GOTO TOPP

    If the LED stays on for one second and off for one second, then
    you are running the frequency you have set in your DEFINE

    For example:

    IF have DEFINE OSC 4 -

    and the above program turns the LED one second ON and one second OFF
    Then you are running at 4MHz

    If it is on for 200milliseconds at off for 200 milliseconds. Then you are running
    at 20MHz.
    Charles Linquist

  6. #6
    Join Date
    Jan 2009
    Posts
    34


    Did you find this post helpful? Yes | No

    Angry

    Quote Originally Posted by Charles Linquis View Post
    Run the program below -

    Set the port to output

    TOPP:
    Toggle LED
    PAUSE 1000
    GOTO TOPP

    If the LED stays on for one second and off for one second, then
    you are running the frequency you have set in your DEFINE

    For example:

    IF have DEFINE OSC 4 -

    and the above program turns the LED one second ON and one second OFF
    Then you are running at 4MHz

    If it is on for 200milliseconds at off for 200 milliseconds. Then you are running
    at 20MHz.


    I kinda thought that's what I had to do...just didn't believe it was that simple!

    So I did that...even though I've 'told' the chip to run the external crystal and defined osc 4...I'm not blinking @ 200ms

    Either the crystal isn't oscillating properly...or I should start flippin' burgers


    BTW: The reason I'm trying to run this 12F683 at 20Mhz is to obtain readings from an accelerometer (aboard an RC aircraft) and control 3 servos all in a relatively smooth way.

    In addition, I've bought XBEE 900 Mhz XSC transceivers and will be passing telemetry information from the aircraft to a ground station. I have more Q's about serial communications from the 12F683 to the XBEE...but that's for another thread. I first have to figure out what I don't know.

    Cheers,

    JOhn.

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


    Did you find this post helpful? Yes | No

    Default

    It does not look like you are setting the config correctly.
    The thread that Joe and I pointed you to should have helped.

    For now try going to the inc file for this chip in the PBP directory. Below is part of it.
    If you are using PM for the assembler change
    device pic12F683, intrc_osc_noclkout, wdt_on, mclr_on, protect_off
    to
    device pic12F683, hs_osc, wdt_on, mclr_on, protect_off

    If you are using MPASM then change
    __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
    to
    __config _HS_OSC & _WDT_ON & _MCLRE_ON & _CP_OFF

    Code:
     device  pic12F683, intrc_osc_noclkout, wdt_on, mclr_on, protect_off
    
            XALL
    
            NOLIST
    
        else
    
            LIST
    
            LIST p = 12F683, r = dec, w = -302
    
            INCLUDE "P12F683.INC"	; MPASM  Header
    
            __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. PICKit2 - warning about configuration words
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 4th August 2009, 14:01
  2. Char. LCD and 18F452 on 20 MHz not work
    By samettin in forum General
    Replies: 11
    Last Post: - 28th July 2008, 09:59
  3. PIC18F2685 config settings for 20 MHz
    By wwilson17 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 31st March 2008, 23:13
  4. 20 MHz + PLL vs 48MHz
    By Demon in forum General
    Replies: 14
    Last Post: - 31st July 2006, 12:02
  5. How to use a 20 MHz resonator on a 16F688
    By Thomas Williams in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st December 2005, 09:18

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