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

Why can PIC18F4550 fail USB enumeration with a healthy 20 MHz crystal?

A USB instrument board gets a replacement 20 MHz passive crystal. Its indicator blinks, and the crystal circuit measures 20 MHz, but the host does not recognize the device. The PIC18F4550 can use one PLL for both the processor and USB while routing their clocks separately. Check the full-speed module's 48 MHz path and the CPU's timing in their own branches.

Set the PLL input before selecting the USB clock

Microchip's clock diagram specifies a fixed 96 MHz PLL driven from 4 MHz. For a 20 MHz passive crystal using the documented HSPLL option, PLLDIV must divide by five. Its field code is binary 100. The PLL input is therefore 4 MHz. For full-speed USB, set USBDIV to one to select the 96 MHz PLL divided by two. Clearing USBDIV instead selects the primary oscillator path, which does not yield the 48 MHz required in this example.

Some programming displays show a divider and others show the raw code. Binary 100 means divide by five here. A project copied from a 16 MHz design might retain divide-by-four, giving five megahertz from the new reference and violating the PLL's fixed input requirement. Check the configuration word before assuming the PLL provides a valid clock at another frequency.

The CPU branch can run at another speed

In HSPLL mode, CPUDIV controls the CPU branch of the same 96 MHz PLL. Divide by two for a 48 MHz system clock or by three for 32 MHz, while leaving the separate USB branch at 48 MHz. Timer0 with its internal instruction clock and bypassed prescaler runs at one fourth of the system rate. The two settings yield 12,000 and 8,000 ticks per millisecond. Keeping the 12,000-tick wait at the slower clock gives 1.5 milliseconds.

If enumeration recovers while an application timing output remains slow, check CPUDIV and the clock assumed by the code. A correct CPU delay does not verify the USB branch. Full-speed USB signals at 12 Mb/s on the wire. That bit rate and the module's 48 MHz input describe different points.

Keep distinct startup and communications evidence

Read FOSC, PLLDIV, CPUDIV, and USBDIV back from the programming record and identify the selected full-speed route. Observe the 20 MHz passive crystal without significantly loading its oscillator circuit. Capture both a CPU timing marker and USB bus activity. If the clock tree checks out, continue with signaling, connection, supply, and descriptor checks.

Test two boards with the same firmware, host, and supply conditions. Include a cold start, host reset followed by reenumeration, and a transfer of known data. Record any configuration differences before comparing oscillator parts. Keep programming bytes, CPU timing, and USB communication results as distinct evidence.

Startup behavior can distinguish two failures. If the first power-up fails but reconnecting works, capture supplies, reset, and the first bus activity. Verify that the selected main clock mode was reached. Compare against a working board to distinguish no bus activity from an incomplete enumeration. Retain the instrument timeline separately from the software log.

For a repeatable comparison, build two test firmware images that differ only in the CPU postscaler. Keep the PLL input and USB selection unchanged. Run the 48 MHz CPU image, then the 32 MHz image. The interface should still signal at full speed while the CPU timing output follows the count example. If only the USB behavior changes, compare the programmed clock and speed-selection fields in the two files. This catches disagreements between build settings and programming notes.

In the component record, specify the crystal package, nominal frequency, load, and lot. In the board test, state whether the fixture observed the oscillator circuit, instruction timing, or the USB bus. After repair, repeat several transfers of known instrument readings. Enumeration and sustained transfers can then be reproduced independently.

If boards fail only after restart, save a readback of the configuration bytes before reprogramming one. Two builds with the same application logic may still select different oscillator modes. Include the clock mode and full-speed selection in the comparison, in addition to checksums for program memory.

References

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.