v. How setting the right oscillator configuration defers on PIC18 and PIC32?

It is important to note that the oscillator configuration highly depends on microcontroller specifications. PIC18FxxJ50 microcontrollers allow for much longer clock signal raise and fall times. This means that you may use a lower quality crystal oscillator and a PIC18F microcontroller would still work flawlessly. You have only to correctly set the software switches. There are many possible configurations, but not all are suitable for USB 2.0 operation. USB 2.0 module needs 48 MHz clock to support high speed data transfer mode (up to 12 Mbps).

USB 2.0 operation requires the use of PIC18 module that multiplies the input clock signal frequency by 24 from 4 MHz to 96 MHz. An additional frequency divider is used in series to half the frequency to 48 MHz. It is now obvious that the input clock signal has to have a frequency of 4 MHz to enable USB module to run on 48 MHz. However, PLL module also includes an input prescaler (a configurable frequency divider) that can divide the input signal frequency by 1, 2, 3, 4, 5, 6, 10 or 12. This enables the microcontroller circuit designer to use various input clock sources with different frequencies.

PIC32 microcontrollers have two PLL modules, one for USB module and the other as a system clock source. They can be configured separately thus there are more options for setting the right parameters in firmware. However, the hardware must also be able to support them. If an external clock source fails to run a PIC32 microcontroller, it automatically switches over to the internal 8 MHz oscillator, but the latter is not sufficient to establish a USB 2.0 high speed connection. Read more on setting a PIC32 software switches here.

Basically, there are three types of oscillator circuits that can be used with PIC microcontrollers. The microcontrollers have an internal 8 MHz oscillator with lower stability level that can only be used for applications that do not need the high speed USB 2.0 data transfer mode. The next option is a built-in internal oscillator circuit that requires only an external crystal resonator. You can either buy the resonator or built the resonator yourself. The latter option is probably required two capacitors with a few pF and a crystal. But it is not always trivial get to the right combination, especially if you have no digital oscilloscope at hand. You can buy a complete crystal resonator, instead. It includes a crystal and two capacitors in one IC (integrated circuit). The third option is to use an external clock source. The external oscillator MUST meet the PIC18 or PIC32 requirement regarding the clock signal raise and fall timers. PIC32 microcontrollers have very strict requirement compared to PIC18 family. The raise time should be at most 5% of the whole clock cycle length and signal low and high times should be at least 45% of the cycle time, each. If you use a 16 MHz oscillator this means that the rise and fall timers may not exceed a little more than 3 ns. Though, it is advisable to opt for TCXO type crystal oscillators like FOX924B that are designed to be used with microprocessors. PIC18 on the contrary allows for 7.5 ns raise and fall times, not depending on the clock frequency.

PLEASE, NOTE: Not all oscillator circuits that work flawlessly with PIC18 will work with PIC32. It oscillator circuit fails to operate within the required specifications a PIC18 microcontroller will fail to operate, but PIC32MX microcontroller would automatically switch over to the internal 8 MHz oscillator. No wonder, why PIC USB 2.0 module would fail to connect to a PC afterwards, but the PIC program in flash RAM would run anyway.