Electronic – Confusion with PIC32MX1XX/2xx datasheet information (clock source for USB)

clockmicrocontrollerpicusbusb device

Maybe there are some experienced "wolves", who could help out to clear out confusion about internal/external clock sources. Particularly, I got lost while reading PIC32 family reference manual, "Section 6. Oscillators".

As for the fact, I know that using external oscillators are recommended for stability, accuracy and flexibility. However, I was trying to figure out if I would be fine using only internal oscillator of PIC32MX250F128D, I do have requirement to establish communication with PC using internal USB hardware.

At initial impression it seemed, that I'd be just fine, then I started reading in greater detail and notice that:

  1. It states that internal oscillator isn't used for normal USB operation:

6.3.4 USB Clock (USBCLK) Generation
The USBCLK can be derived from the 8 MHz internal FRC Oscillator, 48 MHz POSC, or the
96 MHz PLL from the POSC. For normal operation, the USB module requires exact 48 MHz
clock. When using 96 MHz PLL, the output is internally divided to obtain 48 MHz clock. The
FRC clock source is used to detect USB activity and bring USB module out of Suspend mode.
Once USB module is out of Suspend mode, it must use a 48 MHz clock to perform the USB
transactions. The internal FRC Oscillator is not used for normal USB module operation.

  1. Another paragraph states that it can be used, even not very clearly:

The internal 8 MHz FRC Oscillator is available as a clock source to detect any USB activity during USB Suspend mode and bring the module out of the Suspend mode. To enable FRC for USB usage, the UFRCEN bit (OSCCON<2>) must be set to ‘1’ before putting the USB module in Suspend mode.

  1. Then from block diagram, we can see that for the USB we need clock signal of 48MHz, however internal clock is only 8MHz, and it doesn't go throughout any multipliers to USB block:
    Oscillator System Block Diagram

Actually, once I written this post it became more clearly. I still have questions such as, if my goal is to use this MCU as USB device (CDC class(to act as virtual serial port)) I may not need full speed of USB, therefore it may be enough just to use internal clock source of 8MHz? Otherwise, could we conclude that there is no other way out except using external oscillator based on my requirements.

Best Answer

From your quote of the datasheet:

For normal operation, the USB module requires exact 48 MHz clock

and

Once USB module is out of Suspend mode, it must use a 48 MHz clock to perform the USB transactions

Those pretty much say it all. You cannot use the internal 8MHz clock to perform USB transactions. The USB core built in to the PIC requires a 48MHz clock in order to function as a USB slave.

The USB link runs at a fixed speed - both the host and slave must run from clocks of roughly the same speed in order to function, regardless of whether your throughput is using the full capabilities of the link. So just because you are using CDC which doesn't require a lot of throughput, you still need your slave to run at a similar frequency to the host.

You must use an external crystal in order for the device to operate as a USB slave.