2.1 Oscillator Problems and Delays

Symptoms:

  • Device fails to start
  • Delays take longer than expected
  • Timers are not triggering at the expected time

Troubleshooting:

  • Verify the oscillator and timer settings
  • Enable CLKOUT
  • (External clocks only) Check for clock signal
  • (External crystal only) Verify loading capacitors and parameters

One of the most important aspects of the microcontroller is the instruction clock, which determines when instructions are fetched and executed. The default setting for the clock in PIC microcontrollers is to use the external oscillator(1). If this oscillator is not present, the microcontroller may not run, or a clock fail-safe may activate (if enabled and provided). The fail-safe may start the device from one of the internal oscillators, causing unusual timing behavior.

Note: This is applicable to PIC microcontrollers only.

If the user is using MPLAB® Code Configurator (MCC), verify the configuration bits (or fuses) are set to the correct values. Also, check the Clock Control (only present on some devices) to confirm the system oscillator settings are correct after system initialization. Applications written in bare metal may verify the manually set configuration bits or fuses.

Note: In the case of a timer peripheral, also verify the settings (period, operating mode, trigger, etc.) are correctly set.

The CLKOUT line on the microcontroller can be probed(1) with an oscilloscope or universal counter to confirm the clock frequency. If the microcontroller runs from an external oscillator, the clock can be examined by carefully probing the clock input pin.

Note: Measure the external oscillator inputs with a high-impedance probe (such as a 10x) for circuit loading reasons.

With external crystals or ceramic resonators, the problems to look for are:

  • The drive power in the microcontroller - low-frequency crystals can use a lower drive power than the high-frequency crystals
  • The board layout - crystals have to be as close as possible to the microcontroller and surrounded with a ground plane (the latter being for electromagnetic compatibility reasons)
    • The data sheet for the microcontroller has more information about proper PCB layout
  • Capacitive loading requirements are being met (see the crystal data sheet for more information)

Directly probing one side of the crystal with an oscilloscope probe may “work” as a way to observe the crystal’s oscillations. However, the capacitive load presented by the oscilloscope probe may influence the crystal’s operation. See Microchip Application Note AN949,”Making Your Oscillator Work” (DS00000946) or AN2648, “Selecting and Testing 32 kHz Crystal Oscillators for AVR® Microcontrollers” (DS00002648) for more information about setting up crystal oscillators.

Note:
  1. Some clock configurations, such as those using external crystals, are not compatible with CLKOUT. See the device data sheet for more information.