PIC18F Xtal and USB

Discussion in 'General Electronics Chat' started by Dritech, Oct 20, 2013.

  1. Dritech

    Thread Starter Well-Known Member

    Sep 21, 2011
    756
    5
    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.
     
  2. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,646
    759
    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.
     
  3. MrChips

    Moderator

    Oct 2, 2009
    12,421
    3,357
    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.
     
  4. Dritech

    Thread Starter Well-Known Member

    Sep 21, 2011
    756
    5
    Hi, thanks for the replies. Which is the best type of communication USB or UART? Is USB easier to use?
     
  5. MrChips

    Moderator

    Oct 2, 2009
    12,421
    3,357
    You need to describe what you are attempting to do.
    Not all devices support USB and not all devices support UART.
     
  6. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,509
    2,369
    I have used down to 4mhz when using the USART with no adverse signs.

    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: Oct 21, 2013
  7. Dritech

    Thread Starter Well-Known Member

    Sep 21, 2011
    756
    5
    I want to interface Visual Studio in C# with the PIC18F4550.
     
Loading...