View previous topic :: View next topic |
Author |
Message |
joaojprf
Joined: 04 Dec 2007 Posts: 5 Location: Brazil
|
How to calibrate the internal oscillator in pic16f676? |
Posted: Thu Feb 07, 2008 11:05 am |
|
|
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
|
|
Posted: Thu Feb 07, 2008 11:29 am |
|
|
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
|
|
Posted: Thu Feb 07, 2008 11:38 am |
|
|
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
|
|
Posted: Thu Feb 07, 2008 11:42 am |
|
|
Yes, you can do it. If you want to do, go ahead. |
|
|
Ttelmah Guest
|
|
Posted: Thu Feb 07, 2008 3:32 pm |
|
|
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
|
|
Posted: Fri Feb 08, 2008 11:39 am |
|
|
Thanks Ttelmah.
This directive help me to access the register. |
|
|
|