Electronic – Make the oscillator choice

oscillatorpic

I am using a PIC24FJ128GA010 and I need to make an oscillator choice. If I am not wrong, two main oscillator could be used 32KHz and 8 MHz.
1. Do I really need 32KHz oscillator?
2. Element 14 website shows many 8MHz but the Microchip website advice to make a clever choice.

Could you please help me for this choice.

Best Answer

You only need the 32kHz oscillator if you want to have a low speed oscillator present for uses like the RTC (Real Time Clock) peripheral, or low speed system clock operation. It is not required for operation of the microcontroller.

The primary oscillator crystal can be anything from 3.5MHz to 32MHz. If you want to use the PLL (phase locked loop) however, it must be between 3.5MHz and 8MHz. The phase locked loop is used to generate 4x the original frequency*, so you can use an 8MHz crystal and generate 4 * 8MHz = 32MHz for use as the system clock.
* note that other versions of the PIC24 have different PLLs onboard, this one is just the simple x4 version. See note 2 in table below

PIC24 Oscillator

Note that the PIC24 also has two internal oscillators, of 8MHz and 31kHz, so you can use it without an external crystal. The benefits of the crystal are better timing accuracy (needed for things like USB, UART, etc)

The part datasheet is just an overview, for details you should refer to the Family Reference Manual (halfway down the page) The Oscillator section is relevant here.

Selecting a crystal

The PIC oscillator is designed for a parallel resonant (usually AT cut) crystal. Plenty of technical information on choosing the crystal and load capacitors is given in the Oscillator section above, read this thoroughly (particularly section 6.5 and 6.5.2.4).

Unless your applications timing is extremely demanding then the slight variations in temperature and frequency tolerance of different crystals won't matter much, if they do you would be better to look at using a TXCO or OXCO (temperature or oven controlled oscillator)
The frequency tolerance of a typical crystal varies between ±15 and ±100 ppm (parts per million) which is 0.01% and 0.0015%. To compare to the internal RC oscillator, the accuracy is given as ±2% at 25°C, and ±5% between -40°C and +85°C which equates to ±20000 and ±50000 ppm respectively (see part datasheet)
An excellent guide for oscillator design is the Microchip AN588 - PIC oscillator design guide. If you do a search on their site you will get other useful app notes such as:
AN949 - Making your oscillator work
AN849 - Basic PIC oscillator design