Oscillator calibration questions

Thread Starter

ke5nnt

Joined Mar 1, 2009
384
Microcontrollers with internal oscillators have a calibration word programmed into them at the factory, in the last address location. I would like to know a couple things regarding this topic.

Under what circumstances can you accidentally erase the calibration and have to recalibrate? If you get a shiny new PIC and drop a program into it that doesn't have the calibration value in it, does it overwrite the factory setting? In other words, should the first thing I do when I get a new PIC is pop it in the programmer and "read" it so I can see what the factory setting is, and make a note of it to ensure I don't lose it?

It seems I've gone and erased my calibration value, and it also seems that each value is pretty much unique to each PIC that is manufactured, so there's not a "standard value" you can just drop in the thing. Now my PIC appears to be pretty much useless for any kind of semi-accurate timing, let alone accurate timing.

Thanks.
 

thatoneguy

Joined Feb 19, 2009
6,359
PICKit 2 has OSCCAL Regeneration in the latest software version from Microchip. It is under the Tools menu. A Bulk erase from a non-microchip chip programmer will wipe out the value, as well as the bandgap calibration. Microchip tools read these, save them, and write them back after the bulk erase.

It can also be tuned to custom frequencies by writing a value to OSSCAL and testing, though that is tedious.
 

Thread Starter

ke5nnt

Joined Mar 1, 2009
384
Thanks for the reply. Yeah, I use a non PIC programmer. I have a DIY K150. Perhaps it's time I invest in a PICKit, the DIY has been giving me trouble lately anyways. For now, I'll just remember to read the value before I program the first time.
 

thatoneguy

Joined Feb 19, 2009
6,359
Remember, PIC KIt 2, NOT PICKit 3!

For some reason, the PICKit 2 has more features (OSCCAL, Bandgap restoration, UART debugging, logic analyzer) in the standalone program.

The PICKit 3 supports a few more of the higher end (16/32 bit) devices, it didn't originally come with a standalone program for programming, but they finally made one for it, but all it does is program and debug. It won't do ANY of the extra functions the PIC Kit 2 does.

If you plan on working with higher end PICs, get both! I'd actually recommend getting the PICKit 2 with the low pin count demo board. It's overall cheaper than getting them separate, and then you have a "Known Good" fallback to see if your programming setup is messed up, or your circuit when something doesn't work right.
 

Thread Starter

ke5nnt

Joined Mar 1, 2009
384
I'm really glad you said that. I was wondering if I should get the 2 or the 3, guess I know the answer now.

Cheers!
 
Top