PIC18F Xtal and USB

Thread Starter

Dritech

Joined Sep 21, 2011
901
Hi,

I am seeing lots of tutorials where a 20MHz Xtal with 22pF capacitors are used for the PIC18F4550. In the datasheet it is stated they when using a 20MHz Xtal, 15pF capacitors must be used. Does this make any difference??

Also, in the tutorials they suggest to use 20MHz because of the USB module. Does this also apply when using UART??

Thanks is advance.
 

atferrari

Joined Jan 6, 2004
4,771
For the USART you must check the values (calculate using the formulas given in the datasheet) taking into account that clock frequency.

Read the pertinent section and do not try to compare or relate USART with USB.

BTW, the datasheet is clear enough.
 

MrChips

Joined Oct 2, 2009
30,823
Capacitors are required in crystal oscillators in order to present a certain reactive load to the crystal. Capacitor values from 5pF to 33pF are quite common. Changing from 15pF to 22pF will have minuscule effect on the oscillator's frequency. It will not affect the fundamental frequency to any significant degree. Changing the capacitor values by a significant amount may cause the crystal to oscillate at a harmonic of the fundamental frequency.

USB requires specific clock frequencies. If the datasheets call for 20MHz then go with that.

The UART or USART baud rate is also directly dependent on the crystal oscillator. However, there are frequency dividers in the UART/USART module that can be adjusted in order to provide the desired baud.
 

MaxHeadRoom

Joined Jul 18, 2013
28,698
Also, in the tutorials they suggest to use 20MHz because of the USB module. Does this also apply when using UART??

Thanks is advance.
I have used down to 4mhz when using the USART with no adverse signs.

Which is the best type of communication USB or UART? Is USB easier to use?
Using the USART is pretty straight forward, however if using RS232 you need to add a MAX232 IC on the USART I/O.

Max.
 
Last edited:
Top