Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Mon Mar 29, 2004 8:03 pm |
|
|
Are you calibrating the internal oscillator? Quoting from the datasheet:
Quote: |
When calibrated, the internal oscillator provides a fixed
4 MHz (nominal) system clock...
A calibration instruction is programmed into the last
location of program memory. This instruction is a
RETLW XX, where the literal is the calibration value.
The literal is placed in the OSCCAL register to set the
calibration of the internal oscillator. Example 9-1
demonstrates how to calibrate the internal oscillator.
For best operation, decouple (with capacitance) VDD
and VSS as close to the device as possible.
Note: Erasing the device will also erase the preprogrammed
internal calibration value for
the internal oscillator. The calibration value
must be saved prior to erasing part as
specified in the PIC16F630/676 Programming
specification. Microchip Development
Tools maintain all calibration bits to
factory settings.
EXAMPLE 9-1: CALIBRATING THE
INTERNAL OSCILLATOR:
bsf STATUS, RP0 ;Bank 1
call 3FFh ;Get the cal value
movwf OSCCAL ;Calibrate
bcf STATUS, RP0 ;Bank 0
|
Also take a look at Electrical Specifications in the device datasheet (Section 12.0) for information on variation over voltage and temperature. |
|