CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How do I change the OSCCAL with CCS?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Futterama



Joined: 17 Oct 2005
Posts: 98

View user's profile Send private message

How do I change the OSCCAL with CCS?
PostPosted: Thu Feb 09, 2006 2:36 am     Reply with quote

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







PostPosted: Thu Feb 09, 2006 5:13 am     Reply with quote

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:
Code:

#byte OSCCAL=0x90

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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