PDA

View Full Version : Regenerating OSCAL and Bandgap



malc-c
- 3rd August 2006, 11:35
Hi,

I'm posting this on behalf of a friend. He's just getting to grips with PIC programming and PBP. In the course of trying to program his 12F675 pics with a simple "flash an led" code using WinPic software and a serial JDM programmer he has over-written the OSCAL and Bandgap settings and now thinks the pics are wasted and of no use.

Is there a way using the equipment and software to re-generate the OSCAL setting ?

I have a Microchip PicKIT1 which has the option to re-generate the OSCAL value and set the Bandgap to one of three values, so if I screw up its not a problem ;)

Melanie
- 3rd August 2006, 13:43
Both are of little consequence.

The OSCAL value trims the INTERNAL Oscillator. This is only important for timing critical functions. Set the CONFIG fuse settings to give you CLKOUT on GP4 and play with the settings until you get as close to 4MHz as possible using a Frequency Counter.

Alternatively, DEBUG out a string like "abcdefghijk" followed by a CR/LF, in a continuous loop starting at 300 baud, and adjust the OSCAL values until you get something sensible on Hyperterminal. Once you've got it working, increase the baudrate to 2400 or 9600 and repeat for a finer trim setting.

If you don't plan to do timing critical functions it's a complete waste of effort. Get a life, get a beer, get anything, damn PIC costs less than a Dollar USA and how many hours did you plan to spend on this?

The BANDGAP just trims the BOR and POR values. Set the PCON register to enable BOD, have a simple LED program in a loop. Use a variable power supply along with a good DVM to drop the supply voltage until the PIC trips-out. Trim the bandgap until the PIC trips within the value range in the published specifications. A lot of hassle to trim a few millivolts here or there.

malc-c
- 3rd August 2006, 14:03
If you don't plan to do timing critical functions it's a complete waste of effort. Get a life, get a beer, get anything, damn PIC costs less than a Dollar USA and how many hours did you plan to spend on this?

That was my thought to be honest... but like I said I was posting on behalf of a friend, who felt that the pics were usless !

Kman
- 7th August 2006, 15:00
Look for "Recover.bas" in your PBP sample folder. Also here a link "http://users.tpg.com.au/btkelly/pic/osccal_sync.html"

Kman

malc-c
- 7th August 2006, 15:49
Thanks - I'll pass on the info