Specialist Supplier of Crystals & Frequency Control Componentssales@mecxtal.com.cn0755-26500570
MERLIN home / Rednote / System Validation and Replacement

Does clearing OSCFIF return the PIC18F46K22 to its 20 MHz Epson crystal?

No. Microchip treats the PIC18F46K22 oscillator-failure interrupt flag OSCFIF separately from clearing the underlying fail-safe condition. With the monitor correctly enabled, the controller can continue on an internal clock after external oscillator failure. Software can clear the flag without restoring the external clock. The documented recovery paths include reset or toggling OSCCON.SCS1, followed by confirmation against the oscillator startup sequence. A running CPU or a cleared flag does not prove that the crystal is driving the system again.

Consider the 20 MHz Epson FA-238 Q22FA23800001xx, a passive crystal specified with 12 pF load capacitance. The external oscillator circuit still requires qualification. If the actual failover configuration moves from 20 MHz to 16 MHz while retaining the same timer divider, a nominal 1 ms interval becomes about 1.25 ms. This is an illustrative fallback setting, not a claimed default for every board. Serial and timer timing can change while application code still executes.

Record the fault flag, selector state, OSCCON.OSTS and a signal reflecting the actual system timebase before clearing the indication. Initiate recovery through the documented procedure, verify the oscillator and selected source, and then retest peripheral timing. On a suitable low-voltage engineering board, log the induced clock failure, flag clearing and recovery separately. Do not treat clearing the flag, seeing the external waveform again and switching the CPU back as the same event.

Related selection guide: MERLIN Crystal Timing: What Sets PWM and Interrupt Rates on a PIC18F46K22 With a 20 MHz Crystal?

Resource link: https://www.mecxtal.com.cn/en/handbook/20mhz-crystal-pic18f46k22-pwm-postscaler.html

WeChat

MERLIN · TIMING COMPONENTS

Scan with WeChat to contact Sales

Add our WeCom contacts from your usual WeChat app.

On desktop, scan with your phone. On mobile, save the QR image and select it from your album in WeChat Scan.