element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products & Partners
    Products & Partners
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Embedded Forum PIC micro OSC Calibration
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 5 replies
  • Subscribers 503 subscribers
  • Views 804 views
  • Users 0 members are here
Related

PIC micro OSC Calibration

samplerman
samplerman over 16 years ago

Does anyone know what happens to the oscillator calibration codes which are preloaded into most PIC chips when the device is programmed for the first time? Are they wiped out by the programmers' Erase before Program routine? or are they stashed in a secure location away from the chip 'erase function' ? The data sheets are unclear.

Thanks

Carl

  • Sign in to reply
  • Cancel
  • pjclarke
    pjclarke over 16 years ago

    Hi,

     

    Which PIC chip / family are you using -? I can look at data sheet from here.

     

    However under the Osc section you should find some sample code that reads out the factory setting and then initialise it. Common for PIC16 or less when working in ASM code, but think is in start up code if your writings in C.

     

    Paul

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • samplerman
    samplerman over 16 years ago in reply to pjclarke

    HI Paul

    I was asked the question in relation to a PIC12F675-E/SN.PIC12F675-E/SN.. the data sheet quotes

     

    "The entire program memory will be erased, including OSCCAL value, when the code protection is

    turned off"

    also:

    "Erasing the device will also erase the preprogrammed

    internal calibration value for

    the internal oscillator. The calibration value

    must be saved prior to erasing part as

    specified in the PIC12F629/675 Programming

    specification. Microchip Development

    Tools maintain all calibration bits to

    factory settings"

     

    This looks as though it infers that the chip contents should be read into MPLAB and all the calibration constants including the Bandgap calibraton bits be noted and recorded down somewhere before that device is programmed for the first time.

     

    The Microchip routine looks as if it is getting the code from 3FF and then loading it into the OSCCAL reg, but if the calibration code is wiped when you first put a program into the chip, then where does the device look to get the calibration value, or are you expected to put the calbration code at location 3FF when you program the device ( as well as the code section below to actually fetch it)

     

    call 3FFh ;Get the cal value

    movwf OSCCAL ;Calibrate

     

    thanks

     

    Carl

     

     

     

     

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • pjclarke
    pjclarke over 16 years ago in reply to samplerman

    Hi,

     

    Your correct in what you are saying that a bulk erase will wipe out the CAL value. The programming guide says in section 2.3.1.9, that you should first read in the value, verify the value before erasing.

     

    However in the data sheet it states in section 9.2.5.1, "Microchip Development Tools maintain all calibration bits to factory settings." therefor saying that if you program your PIC with MPLAB will read in the values (CAL and BG), verify them before it tells the PIC to bulk erase. therefore automatically saving the values so you don't have to worry about it.

     

    If you have your own programming tool or a 3rd party tool you will need to find out if they do this for you - other wise you can 'just' let MPLAB get on with it.

     

    Hope that helps,

     

    Paul

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • samplerman
    samplerman over 16 years ago in reply to pjclarke

    Thanks Paul

     

    I also saw the comment about the Mchip dev tools, but was still unsure about what the dat sheet was actually trying to say.

    In a nutshell, as long as we use the MCHIP dev tools then the MPLAB will take care of the reading and rewriting of the calbration values transparently to our normal programming.

     

    Thanks again

     

    Carl

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • MicrochipRTCfr
    MicrochipRTCfr over 16 years ago in reply to samplerman

    Hi,

     

    You can find a couple of links and appnotes which explain how you can implement Re-calibration of PICs :

     

    * http://ww1.microchip.com/downloads/en/AppNotes/00244A.pdf

    * http://picprojects.org.uk/projects/recal/recal.htm

     

    regards

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube