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 to calibrate the internal oscillator in pic16f676?

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



Joined: 04 Dec 2007
Posts: 5
Location: Brazil

View user's profile Send private message MSN Messenger

How to calibrate the internal oscillator in pic16f676?
PostPosted: Thu Feb 07, 2008 11:05 am     Reply with quote

Hello,

I am using pic16f676. How can I calibrate the internal oscillator. The datasheet show that I have to write some value into the OSCCAL register, I understand this but the problem is how to access this register? The 16f676.h file doesn't mention anything to access this register, it doesn't has a instruction like the Timer1 has (for example, SETUP_TIMER_1()).

Thanks,

João Paulo.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 07, 2008 11:29 am     Reply with quote

The Microchip factory programs the value into the PIC, and the CCS
compiler puts in code to read the value and put it in the OSCCAL register.
Normally, you don't have to do anything.

If you use MPLAB (and I assume also CCS IDE) then during programming
the special location with the OSCCAL value is protected. It won't
be over-written.
joaojprf



Joined: 04 Dec 2007
Posts: 5
Location: Brazil

View user's profile Send private message MSN Messenger

PostPosted: Thu Feb 07, 2008 11:38 am     Reply with quote

I'm using MPLAB and CCS compiler. But the pic16f676's datasheet show that you can calibrate this oscillator writing the OSCCAL register. So it's impossible to write a value in OSCCAL register?

Thanks for help.

João Paulo.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 07, 2008 11:42 am     Reply with quote

Yes, you can do it. If you want to do, go ahead.
Ttelmah
Guest







PostPosted: Thu Feb 07, 2008 3:32 pm     Reply with quote

The OSCAL register is just a register. It can be accessed using the #byte directive if required. The value put into this adjusts the processor clock speed. The chip manufacturer, stores a calibration value for this register, into the top location of the program memory, when the chip is manufactured. The compiler _automatically_ copies this value, into the OSCCAL register during boot.
Now, the value will never be very good. The accuracy of the oscillator, changes by several percent with temperature, and with fluctations in the supply.
As PCM programmer says, you can try changing the value if you want, but you are unlikely to get any long term improvements...

Best Wishes
joaojprf



Joined: 04 Dec 2007
Posts: 5
Location: Brazil

View user's profile Send private message MSN Messenger

PostPosted: Fri Feb 08, 2008 11:39 am     Reply with quote

Thanks Ttelmah.

This directive help me to access the register.
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