PIC crystal, simple question, pins

Discussion in 'Embedded Systems and Microcontrollers' started by Gag14, Feb 13, 2018.

  1. Gag14

    Thread Starter New Member

    Jan 23, 2018
    23
    0
    Hi
    I use a crystal in my project , how should I set the pins , as outputs or inputs ?

    thank you .
     
  2. ericgibbs

    Moderator

    Jan 29, 2010
    3,750
    711
    hi Gag,
    We need more details of the circuit to which the xtal is connected.
    E
     
  3. Gag14

    Thread Starter New Member

    Jan 23, 2018
    23
    0
    thank you

    it is 16f628 and 16f877 ,
    RA7, RA6 and C1,C2
     
  4. AlbertHall

    AAC Fanatic!

    Jun 4, 2014
    5,276
    1,231
    In the configuration settings you select the oscillator type depending on the crystal frequency. That takes over those two pins and you don't need to do anything else.
     
    Gag14 likes this.
  5. ericgibbs

    Moderator

    Jan 29, 2010
    3,750
    711
    hi,
    All you have to do is to connect the xtal across the 16F877 pins 13 and 14. [40 pin DIP]

    E
     
  6. Gag14

    Thread Starter New Member

    Jan 23, 2018
    23
    0
    thank you
     
  7. Gag14

    Thread Starter New Member

    Jan 23, 2018
    23
    0
    so when I set the ports
    I just put this line ?
    movlw b'10000000' ;set Portc
    movwf TRISC

    I need one input and other as outputs .
    and the configuration setting for crystal.
    is it correct ?

    for 16f877a
     
  8. AlbertHall

    AAC Fanatic!

    Jun 4, 2014
    5,276
    1,231
    That will make RC7 an input and RC6:RC0 as outputs.
     
  9. Gag14

    Thread Starter New Member

    Jan 23, 2018
    23
    0
    But the crystal pins can not be used , correct ? as outputs or inputs
     
    Last edited: Feb 13, 2018
  10. ericgibbs

    Moderator

    Jan 29, 2010
    3,750
    711
    hi,
    The 628 and 877 do not have a main internal oscillator block, so when a xtal is used, those pins are committed to the osc function.
    E
     
  11. Gag14

    Thread Starter New Member

    Jan 23, 2018
    23
    0
    628 does have an internal oscillator.
    thank you
     
  12. be80be

    AAC Fanatic!

    Jul 5, 2008
    1,276
    231
    You set the configure on the 16f628
    Screenshot from 2018-02-13 19-33-34.png
     
    Gag14 likes this.
  13. ericgibbs

    Moderator

    Jan 29, 2010
    3,750
    711
    Hi Gag,
    You are correct.
    When I make a mistake, I back track to find out why.
    I called up my 16F628 d/s and looked at the 'Special Features'.
    On the PDF, it did not actually say 'Internal Oscillator'.
    Re-checked on a 16F628A d/s and it says 'Internal Osc' for 16F628.
    My error., should have taken more time looking.! :oops:

    E
     
  14. AlbertHall

    AAC Fanatic!

    Jun 4, 2014
    5,276
    1,231
    It did say it, just not so prominently.
     
  15. ericgibbs

    Moderator

    Jan 29, 2010
    3,750
    711
    hi Albert,
    I believe that is what I said, in my corrective post.
    'On the PDF, it did not actually say 'Internal Oscillator'.

    Don't misunderstand me, I appreciate your feedback.

    E
     
  16. Gag14

    Thread Starter New Member

    Jan 23, 2018
    23
    0
    hi
    thank you all for help

    it has dual speed,
    How to set it to 4 Mghz ? I know other speed is 48 khz
     
  17. be80be

    AAC Fanatic!

    Jul 5, 2008
    1,276
    231
    Like this you set the pcon register
    Screenshot from 2018-02-14 18-35-21.png
     
    Gag14 likes this.
  18. Gag14

    Thread Starter New Member

    Jan 23, 2018
    23
    0
Loading...