DEFINE OSCCON_1K 1 ' Set OSCCAL for 1K device to accurize osc
DEFINE OSCCAL_1K 1 or DEFINE OSCCAL_1K 2 is only used for a device that has the factory oscillator calibration value stashed in the last program memory location.
What this does is tell PBP to insert a short piece of assembler code that jumps to the last program memory location, fetches and loads this factory cal value into the OSCCAL register.
Code:
ifdef OSCCAL_1K
LIST
call 03ffh ; Get oscillator calibration for 1K
MOVE?AB OSCCAL ; Set oscillator calibration
NOLIST
else
ifdef OSCCAL_2K
LIST
call 07ffh ; Get oscillator calibration for 2K
MOVE?AB OSCCAL ; Set oscillator calibration
NOLIST
endif
endif
For the 12F683 you don't need this. Just write directly to OSCCON to set the internal osc frequency. The default power-on frequency for internal osc is 4MHz. The datasheet shows the different values to write to OSCCON for different frequencies.
Bookmarks