Here is Microchip's application note on how to auto-recalibrate the internal oscillator on PIC12F6XX chips in the event that it is lost.
http://ww1.microchip.com/downloads/e...tes/00250a.pdf
You can get the source code by searching the Microchip site for
an250.zip.