Re: High accuracy timer in sleep mode
Yes, You may well use a crystal with a different frequency.
The Amplifier is inside the PIC microcontroller,
it is a linear analog amplifier with some automatic gain control (AGC) circuit.
The amplifier have a wide frequency range around the nominal frequency,
so will adapt to the resonance frequency of the Crystal that is connected.
The Circuit connected to the oscillator pins shall be the external crystal resonator and 2 small capacitors.
There is Circuit diagram in Oscillator section of the Datasheet.
Circuit for Primary Crystal Oscillator, and Secondary Crystal Oscillator, are the same.
Capacitor values depend upon what capacitor values that was used when the Crystal was trimmed during production. Typical values may be between 9 pF and 22 pF.
If a different capacitor value from what was used when crystal was trimmed, then frequency will be wery slightly different.
I have observed a secondary crystal oscillator without anything connected,
It did oscillate happily, but nowhere near the nominal frequency.
It may depend somewhat upon what device type is used,
If you read Datasheet more carefully, examining: Electrical Characteristics chapter,
there may be specification of Frequency range for the Secondary oscillator,
or the Primary oscillator in LP mode.
For PIC18FxxK22 devices, the frequency range is between 5 kHz and 200 kHz.
The reason for using 32.768 kHz crystal, is that these are mass-produced for use in digital wristwatches and other clocks, and have low price and good accuracy.
It is also possible to connect a complete, self-contained external oscillator.
There are some external MEMS oscillators that promise better accuracy than typical low-cost crystal resonators.