how to use external crystal?


Closed Thread
Results 1 to 27 of 27

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: how to use external crystal?

    Deleted...........
    Last edited by towlerg; - 5th March 2015 at 04:03.

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: how to use external crystal?

    tbarania, How are you loading the program into the PIC? If you are using a bootloader the " __config1 _FOSC_HS & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _IESO_ON & _FCMEN_ON & _LVP_OFF & _WRT_OFF" statement is NOT being executed.
    Dave Purola,
    N8NTA
    EN82fn

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,682


    Did you find this post helpful? Yes | No

    Default Re: how to use external crystal?

    I have a bunch of 20MHZ low profile xtals that are happiest with _FOSC_XT an 22pF caps , had me guessing for a bit

  4. #4
    Join Date
    Oct 2014
    Posts
    17


    Did you find this post helpful? Yes | No

    Default Re: how to use external crystal?

    I've tried

    #config
    __config1 _FOSC_HS & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _IESO_ON & _FCMEN_ON & _LVP_OFF & _WRT_OFF
    #endconfig

    at the top the basic program. I compile and load the hex file into MPLAB and program the chip using the PICSTART Plus. I leave the configuration bits "set in code" since I'm assuming that is what the above is supposed to take care of. Apparently it doesn't, rather the PIC reverts to the 4MHz internal oscillator. I also set the OSCCON to %01101000 which is supposed to use bits FOSC 0-2 to set the oscillator choice.

    I also tried defining the config1 register to set it up to use the external crystal: DEFINE CONFIG1 $EFC2 Maybe defining is not the right approach and I need to do some sort of assembly code snippet.

    I can select the 8MHz internal oscillator by setting OSCCON, so I don't know why it won't let me select an external crystal.

  5. #5
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: how to use external crystal?

    I wonder if #config/#endconfig is case sensitive like DEFINE? I know to say define osc 8 won't work but DEFINE OSC 8 does.

    The manual shows how to do some conditional compiles but the CONFIG item is in caps.
    Last edited by AvionicsMaster1; - 8th March 2015 at 02:03. Reason: clarification

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: how to use external crystal?

    Quote Originally Posted by AvionicsMaster1 View Post
    I wonder if #config/#endconfig is case sensitive like DEFINE? I know to say define osc 8 won't work but DEFINE OSC 8 does.

    The manual shows how to do some conditional compiles but the CONFIG item is in caps.
    Pretty sure define OSC 8 works too
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: how to use external crystal?

    I'm sure there are many variations and I appreciate you adding one. My point was that the config statement

    #config
    __config1 _FOSC_HS & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _IESO_ON & _FCMEN_ON & _LVP_OFF & _WRT_OFF
    #endconfig
    doesn't look like the one in the manual. There are space at the beginning of the line __config and after each & that are not in the config statement above. I realize the config statement is ASM and therefore only the fuse is case sensitive but I thought it at least worth the effort.

    The manual also shows #CONFIG/#ENDCONFIG in caps. Just sayin'.

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    2,682


    Did you find this post helpful? Yes | No

    Default Re: how to use external crystal?

    for pbp3
    #CONFIG
    __config _CONFIG1, _HS_OSC & _WDT_ON & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOR_ON & _IESO_ON & _FCMEN_ON & _LVP_OFF & _DEBUG_OFF
    __config _CONFIG2, _BOR40V & _WRT_OFF
    #ENDCONFIG


    for pbp 2.6
    ASM
    __config _CONFIG1, _HS_OSC & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOR_ON & _IESO_ON & _FCMEN_ON & _LVP_OFF & _DEBUG_OFF
    __config _CONFIG2, _BOR40V & _WRT_OFF
    ENDASM

    I tried #CONFIG/#ENDCONFIG and #config/#endconfig and both work therefore its not case sensitive


    this is just wrong for a PIC16F886
    #config
    __config1 _FOSC_HS & _WDTE_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_ON & _IESO_ON & _FCMEN_ON & _LVP_OFF & _WRT_OFF
    #endconfig
    ps
    I'm surprised it can compile
    Last edited by richard; - 9th March 2015 at 01:28. Reason: ps OPPS MAKE IT HS_OSC

Similar Threads

  1. 1 x external crystal oscillator for multiple PICs
    By harryweb in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th November 2013, 15:05
  2. Help using this crystal?
    By Kamikaze47 in forum General
    Replies: 5
    Last Post: - 14th November 2009, 15:48
  3. 16f877A and tmr1 external crystal question
    By comwarrior in forum General
    Replies: 3
    Last Post: - 13th July 2009, 01:40
  4. Pic or Crystal
    By jetpr in forum General
    Replies: 2
    Last Post: - 16th September 2008, 02:56
  5. Crystal
    By leonel in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 12th April 2005, 17:05

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts