|
|
View previous topic :: View next topic |
Author |
Message |
Futterama
Joined: 17 Oct 2005 Posts: 98
|
How do I change the OSCCAL with CCS? |
Posted: Thu Feb 09, 2006 2:36 am |
|
|
Hello forum,
How do I change the OSCCAL value in a PIC12F675 with CCS?
My PICkit 2 programmer have a OSCCAL recalibration feature, but the OSC is running way too fast even after calibrating it with PICkit 2.
If I use CCS to make a LED toggle every 10 seconds, the LED will toggle every 7 seconds. With a factory calibrated PIC, the LED will blink every 10 seconds.
So, please post some code on how to change the OSCCAL value.
Thanks.
Regards,
Futterama |
|
|
Ttelmah Guest
|
|
Posted: Thu Feb 09, 2006 5:13 am |
|
|
First, find out what is wrong with the PICKit2. You already know that if the calibration value is 'right', CCS handles it correctly, so something is obviously screwed in the PICKit calibration routine. I'd suspect it is putting a value of zero, or something similar, resulting in the oscillator being tuned as far off as possible!...
OSCCAL, is just an internal register. It is at address 0x90, so:
Will allow you to write a value to the OSCCAL register. However this will not change the stored calibration value (which will be reset on the next bootup). Unfortunately, the 12F675, does not allow you to change the contents of the program memory from inside the code, so having got a value that works,you will need to take this, turn it into a 'retlw' instruction (value | 0x3400), and program the resulting value into address 0x3FF, to have the chip wake up at the right speed in the future.
You could however store your own value into the EEPROM, and add a little code to load this on bootup. However it seems a really complex kludge, when getting the calibrator to work right, would be simple...
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|