Pic16f18857 clock setup


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Jan 2010
    Posts
    19

    Default Pic16f18857 clock setup

    I'm hitting my head against the wall now. I can't seem to figure out this new chip. I just want to get it up and running with the internal oscillator at 32Mhz. When I blink an led with a 1 sec interval it's way to fast. If anyone can give me a walk through that would be great.

  2. #2
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Pic16f18857 clock setup

    If it is blinking too fast, that would point to your clock speed being too high which is extremely unlikely. Are you absolutely sure your code is correct? Perhaps you should post your blink code.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,520


    Did you find this post helpful? Yes | No

    Default Re: Pic16f18857 clock setup

    Yes, it's not very likely that the PIC is running faster than 32MHz.
    There's two parts to it. Get the PIC to actually run at the desired frequency and inform the compiler what that speed is so it can get its timing calculations correct. If you don't tell the compiler that you're running the PIC at 32MHz it defaults to 4MHz and your PAUSE 1000 will in effect become a PAUSE 125.

    /Henrik.

  4. #4
    Join Date
    Jan 2010
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Pic16f18857 clock setup

    I was following the data sheet and it must be set for 32Mhz because when I used a pause of 1000 and hooked up the oscilloscope to it I was getting 125ms. I used the define 32 in PBP but it doesn't seem to work. I've never used a chip like this, the oscon register is different. I'll try again tomorrow.

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,520


    Did you find this post helpful? Yes | No

    Default Re: Pic16f18857 clock setup

    Code:
    define OSC 32
    OSC is case sensitive, the rest is not.

    /Henrik.

  6. #6
    Join Date
    Jan 2010
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: Pic16f18857 clock setup

    I've tried so many thing now with no luck. Here is the config setup in 16f18857.inc file. A pause 1000 led on & off program is giving me 125ms on the scope.
    #CONFIG
    __config _CONFIG1, _FEXTOSC_HS & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON
    __config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF
    __config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_ON & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
    __config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_OFF
    __config _CONFIG5, _CP_OFF & _CPD_OFF

    #ENDCONFIG

    It's my understanding that on reset the internal clock will be running at 32Mhz with these fuses set. I've tried simply setting Define OSC 32, and adding OSCFRQ = %00000110.
    There are three OSCCON registers and OSCEN register. I'm off in the weeds and don't know which way to go at this point.

    I did notice that when I program the chip with meProg that the configuration HFINTOSC WITH 2X PLL was set instead of HFINTOSC like the fuse is set for. I changed that and my blink program goes from 125ms to 2sec. For what it's worth. Any help would be appreciated thanks.

Similar Threads

  1. external clock / internal clock
    By grounded in forum General
    Replies: 4
    Last Post: - 31st May 2008, 17:44
  2. Use Button For setup
    By tump in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 21st November 2007, 19:43
  3. LCD setup
    By ruijc in forum General
    Replies: 11
    Last Post: - 19th November 2007, 09:04
  4. pic12f683 setup
    By erice1984 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th July 2007, 11:48
  5. How to setup Bootloader
    By koossa in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th January 2006, 19:52

Members who have read this thread : 1

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

Posting Permissions

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