PDA

View Full Version : Regenerating OSCCAL



ardhuru
- 4th August 2011, 17:02
Here's something that might help some folks who have erased their OSCCAL values.

I use a Pickit2, so I usually dont end up erasing the OSCCAL, and even if I do the Pickit2 generally regenerates it.

But somehow, today, I had a chip that consistently said 'invalid OSCCAL', and sure enough it was erased. For some reason, Pickit2 failed to regenerate the value, although it was willing to let me specify it manually.

So, just run the following code:
FOR N = 1 to 255
OSCCAL = N
DEBUG #N,13,10
PAUSE 200
TOGGLE LED
NEXT

You'll get a string of incrementing numbers on your terminal, which are somewhat close to the value, as for these values the serial comms work.

Just take the average of the first and the last, and there you are, your OCSCAL value.

dhouston
- 4th August 2011, 18:06
FOR N = 1 to 255 STEP 254
OSCCAL = N
DEBUG #N,13,10
PAUSE 200
TOGGLE LED
NEXTCan we do this?