Datasheet
ADuC7033
Rev. B | Page 70 of 140
User code then reads back the value of the low power oscillator
calibration counter. There are three possible scenarios:
• OSC0VAL0 = OSC0VAL1. No further action is required.
• OSC0VAL0 > OSC0VAL1. The low power oscillator is
running slow. OSC0TRM must be decreased.
• OSC0VAL0 < OSC0VAL1. The low power oscillator is
running fast. OSC0TRM must be increased.
When the OSC0TRM is changed, the routine should be run
again and the new frequency checked.
Using the internal, precision 131 kHz oscillator, it takes
approximately 4 ms to execute the calibration routine. If the
external 32.768 kHz crystal is used, the time increases to 16 ms.
Prior to the clock calibration routine being started, it is required
that the user switch to either the precision 131 kHz oscillator or
the external 32.768 kHz watch crystal to serve as the PLL clock
source. If this is not done, the PLL can lose lock each time
OSC0TRM is modified. This increases the length of time it
takes to calibrate the low power oscillator.
BEGIN
CALIBRATION
ROUTINE
WHILE
OSC0STA[0] = 1
INCREASE
OSC0TRM
DECREASE
OSC0TRM
OSC0VAL0 < OSC0VAL1 OSC0VAL0 > OSC0VAL1
END
CALIBRATION
ROUTINE
IS ERROR WITHIN
DESIRED LEVEL?
OSC0VAL0 = OSC0VAL1
NO
YES
06847-028
Figure 30. OSC0TRM Calibration Routine
OSC0TRM Register
Name: OSC0TRM
Address: 0xFFFF042C
Default
Va lu e:
0xX8
Access: Read/write
Function: This 8-bit register controls the low power
oscillator trim.
Table 47. OSC0TRM MMR Bit Designations
Bit Description
7 to 4 Reserved. Should be written as zeros.
3 to 0 User Trim Bits.
OSC0CON Register
Name: OSC0CON
Address: 0xFFFF0440
Default
Va lu e:
0x00
Access: Read/write
Function: This 8-bit register controls the low power
oscillator calibration routine.
Table 48. OSC0CON MMR Bit Designations
Bit Description
7 to 5 Reserved. Should be written as 0.
4 Calibration Source.
Set to select external 32.768 kHz crystal.
Cleared to select internal precision 131 kHz
oscillator.
3
Calibration Reset. Set to reset the calibration
counters and disable the calibration logic.
2 Set to Clear OSC0VAL1.
1 Set to Clear OSC0VAL0.
0 Calibration Enable.
Set to begin calibration.
Cleared to abort calibration.