OSCTUNE and 12F683


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263

    Question OSCTUNE and 12F683

    I'd like to run a 12F683 as close to 131.2 kHz as possible.

    I presume I can select 125 kHz using OSCON.

    But I'm not able to figure out how to use OSCTUNE (page 24 of the data sheet)--or can I even do that to get the desired result?
    Last edited by RussMartin; - 15th December 2008 at 05:22.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by RussMartin View Post
    I'd like to run a 12F683 as close to 131.2 kHz as possible.
    I presume I can select 125 kHz using OSCON.
    But I'm not able to figure out how to use OSCTUNE (page 24 of the data sheet)--or can I even do that to get the desired result?
    Should be able to do that. It doesn't say in that particular datasheet, but I seem to remember reading somewhere that OSCTUNE does about +/-12% worth of tweaking to the internal oscillator. You've got +15 and -15 steps to work with, each 'step' worth about .8% if that +/-12% total is correct.
    So, presuming that the internal oscillator will actually run at exactly 125khz, you need 131.2khz, a 5% increase. 5 / .8 = 6.25, so OSCTUNE = 6 should give you +6.25% from the nominal 125Khz, which comes out to about 132.5khz.
    Set your config's for INTOSC or INTOSCIO...
    Set OSCCON = $11, internal oscillator selected, 125khz selected
    Set OSCTUNE = 6 and assuming the config words took correctly, you should be running at 132.5khz.
    And you'll probably have to change OSCTUNE by 1 or 2 in either direction to get nice and close to 131.2Khz.
    If you set INTOSC instead of INTOSCIO, you should get Fosc/4 on the OSC2 pin, which in your case, you should get 32.8khz. Hope you've got a tight freq counter or a good o'scope!

  3. #3
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    If you set INTOSC instead of INTOSCIO, you should get Fosc/4 on the OSC2 pin, which in your case, you should get 32.8khz. Hope you've got a tight freq counter or a good o'scope!
    Thanks for the suggestions. I don't know why I can't find what I need in the 12F683 data sheet but (as I'm sure you've noticed), Microchip's data sheets aren't always as user-friendly as they perhaps could be.

    And I've got both a good (but old) frequency counter (Hewlett-Packard 5300B that last calibrated at 200 ppb) and of course I've got a scope . . . three, right now. (Although my venerable Philips PM3266 is a dinosaur.)

    Interestingly, I intend to use that 32.8 kHz coming out. Although I can probably make do with anything between 32 and 34 kHz, so the tuning may not be as fussy as I am.

    Again, thanks.
    Last edited by RussMartin; - 15th December 2008 at 06:31.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by RussMartin View Post
    Interestingly, I intend to use that 32.8 kHz coming out. Although I can probably make do with anything between 32 and 34 kHz, so the tuning may not be as fussy as I am.
    It might be more accurate to run the PIC as fast as you can (8Mhz on the internal) and write a blinky LED to give you ~32khz on a single pin.
    Code:
    main: led (whatever pin) = 1
    pauseus 29
    led = 0
    pauseus 28
    goto main
    1 cycle for each LED=x statement, 2 cycles for goto, 57 cycles for each pause = 61 cycles total.
    8Mhz / 4 = 2 MIPS / 61 cycles = 32,768 Hz.
    Then, between changing the pauseus values, and tweaking OSCTUNE, you should get dead-on exactly what you really want.

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