PDA

View Full Version : upgrade to PBP 2.46 and using 12F683



peterdeco1
- 20th March 2005, 18:49
Hello Everybody. I have several templates to build code on. Here is my 12F675 template:
ANSEL = 0 'all inputs digital
CMCON = 7 'comparators off
DEFINE OSCCAL_1K 1 ' Set OSCCAL for 1K device to accurize osc
X VAR BYTE ' use for 256 step ADC result
'uncomment & use the following lines for 1024 step conversion
'X VAR WORD
'DEFINE ADC_BITS 10 ' Set number of bits in result
'DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
'ADCON0.7=1 ' Right justification for 10-bit A/D
************************************************** *****
Now, I've upgraded to version 2.46 and want to use 12F683 pics. YES! I studied the datasheet! and found some minor differences. Seems they renamed CMCON to CMCON0 and OSCCAL to OSCCON. So I created a template like the above. Here it is:
CMCON0 = 7 'comparators off
ANSEL = 0 'all inputs digital
DEFINE OSCCON_1K 1 ' Set OSCCAL for 1K device to accurize osc
X VAR BYTE ' use for 256 step ADC result
'uncomment & use the following lines for 1024 step conversion
'X VAR WORD
'DEFINE ADC_BITS 10 ' Set number of bits in result
'DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS
'ADCON0.7=1 ' Right justification for 10-bit A/D
************************************************** *****
Am I correct in assuming this template is equivalent to a 12F683 as the above template for the 12F675? Am I missing something here that may haunt me later. I am awaiting the arrival of the new pics and would like to get an early start on the code. Thank you. - Peter

Bruce
- 21st March 2005, 22:53
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.


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.

khoog
- 22nd March 2005, 01:27
Peter, What's PBP 2.46? Latest rev I saw on the picbasic site was PBP 2.30. Did I miss something?

Acetronics2
- 22nd March 2005, 07:13
Hi, Khoog

MANY Things ... Have a trip to melabs' site !!!

Alain