cyrstal and capacitors setup

Status
Not open for further replies.

jbchrist

New Member
Hello,

I have been looking for some information on how & why they setup the crystal the way they do. Particularly, how do they choose the size of capacitor?

I have a 8 Mhz crystal and I am going to use it on a PIC 16F688 I don't know what size of capacitor to get. How do you calculate it and why?

Also I have seen some resistors thrown into the circuit, and am not sure why.

I would greatly appreciate it if you could point me in the right direction.

John
 
Yes, the datasheets suggest suitable values, but they aren't critical - I generally use anything from 10pF to 47pF, depending what's to hand.
 
Surprisingly I can't fins the 'usual' table with suggested values for that pic
As Nigel said, they're not critical. I would choose 15 or 22 pF.

That PIC has an 8MHz internal oscillator, that allows you to save a crystal and two capacitors and it's suitable for most applications.
 
Last edited:
well the real reason I am looking into using a crystal is I am trying to communicate with my pc, and can't seem to do it. All I want to do is fill up the hyperterminal window a whole bunch of "r".

A friend suggested that perhaps the internal oscillator is working good enough.

I am using the a PIC16F688 which has a EUART. I am writing my program in Proton+ PIC Basis. The attached file is a block diagram of the setup.

When I start it up on the Serial LCD I get exactly what I asked for an "r" every second. On the PC I get "?" every second.

Here is my code is Proton+

Code:
'------------[Hardware setup]---------------------------- 
Device 16F688
Config INTRC_OSC_NOCLKOUT,_     'Internal clock no clock out
        WDT_OFF,_               'Watchdog Timer OFF
        PWRTE_ON,_              'Power-up Timer ON
        MCLRE_OFF,_             'Memory clear pin OFF 
        CP_OFF,_                'Code Protection OFF
        CPD_OFF,_               'Data Code Protection OFF
        BOD_OFF,_               'Brown Out Detection OFF
        IESO_OFF                'Internal External Switch Over OFF 
XTAL = 8    
ALL_DIGITAL = true
'HSERIAL_BAUD = 9600                ' Set baud rate to 9600
HSERIAL_BAUD = 4800                ' Set baud rate to 9600
HSERIAL_TXSTA = %00100000       ' Enable transmit and asynchronous mode 

DelayMS 1000 ' Wait for the PICmicro to stabilise 
'-------[MAIN PROGRAM LOOP STARTS HERE]----------------------------------

While 1 = 1 ' Create an infinite loop 
      HRSOut "r"
      DelayMS 1000
Wend
 

Attachments

  • sch1.pdf
    11.2 KB · Views: 274
I can't help you with BASIC, but I find a discrepancy between
Config INTRC_OSC_NOCLKOUT 'Internal clock no clock out
and
XTAL = 8

If you select the internal oscillator, the default frequency is 4 MHz. You can change it in the OSCCON register.
 
Every PIC I've ever used works fine at 9600 baud with an internal oscillator, are you using a MAX232?, you MUST invert the data when using the hardware USART - as a MAX232 does.
 
I dont know proton at all but..

Looking at your code..

Code:
'------------[Hardware setup]---------------------------- 
Device 16F688
Config INTRC_OSC_NOCLKOUT,_     'Internal clock no clock out
        WDT_OFF,_               'Watchdog Timer OFF
        PWRTE_ON,_              'Power-up Timer ON
        MCLRE_OFF,_             'Memory clear pin OFF 
        CP_OFF,_                'Code Protection OFF
        CPD_OFF,_               'Data Code Protection OFF
        BOD_OFF,_               'Brown Out Detection OFF
        IESO_OFF                'Internal External Switch Over OFF 
XTAL = 8    
ALL_DIGITAL = true
'HSERIAL_BAUD = 9600                ' Set baud rate to 9600
[B]HSERIAL_BAUD = 4800                ' Set baud rate to 9600[/B]
HSERIAL_TXSTA = %00100000       ' Enable transmit and asynchronous mode 

DelayMS 1000 ' Wait for the PICmicro to stabilise 
'-------[MAIN PROGRAM LOOP STARTS HERE]----------------------------------

While 1 = 1 ' Create an infinite loop 
      HRSOut "r"
      DelayMS 1000
Wend

HSERIAL_BAUD = 4800 ' Set baud rate to 9600

Have you entered the wrong Value here? 4800 when your comment says 9600..

Just curious.
 
It is a direct result of copy & paste. People(or at least I myself) do that all the time while debugging. If you look up one line, you'll know why the comment does not match actual action.

Yeah, I know its bad, but the offending line will be deleted later if the code still doesn't work.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…