Menu

Help with Calibrating Internal Oscillator

Help
Keith
2012-12-06
2013-05-30
  • Keith

    Keith - 2012-12-06

    Once again I am looking for help with what might be a simple topic or yet again, another dopey question.  I have written some code for a 12F202 but when I want to program a second or third chip with the same code, I have to adjust the code parameters. This  makes me think the differences I’m finding  is probably in the internal oscillator.

    I have been over the Microchip Memory Programming Specification like a rash, and I see it draws reference to OSC Cal in several places but to be truthful, it may well be written in Swahili, Greek or some other obscure language as either ways it is beyond my comprehension.

    Is there a straightforward bit of scratch code anywhere which I can scrounge?

    Or can anyone throw a little bit of light on this topic as it is beginning to look a better kept secret than a Harry Potter Spell….  

     
  • joe rocci

    joe rocci - 2012-12-07

    Where's tour code?

     
  • Mauried

    Mauried - 2012-12-07

    In most of the 12F series chips, the OSCCAL register allows you to fine tune the internal oscillator up and down from its nominal value.
    To accurately set the oscillator, you need some means of measuring its frequency, like a frequency counter, and then if its not what you want, you can vary the value in the Osccal register to move it up and down.
    If your code is critical, in so far as needing an accurate oscillator frequency, then you should look at using an external crystal oscillator.

     
  • Keith

    Keith - 2012-12-08

    Thank you kindly for your reply. This is the first practical explanation I have come across covering  the mystic surrounding this topic.

    I had thought and hoped that there would be a code string or a routine  I could include which would not necessarily calibrate the internal oscillator at a specific frequency but standardise the oscillator frequency across three or more devices. (I’m not making this too clear am I?)

     
  • Mauried

    Mauried - 2012-12-08

    The Internal oscillators are simply RC oscillators and they drift over time.
    Some of the 12F series chips, the 12F675 for example,  includes a calibration value in the last memory location when the chip is made, and if you read this value and then write it into OSCCAL it will set initially the frequency to 4 Mhz or close to it.
    Unfortunately, many of the programmers for programming PICS wipe the memory map when they first program. so this value gets lost.

    What kind of program are you running that needs the internal oscillators to be so precise.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.