PIC18F25K22 Oscillator Settings


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2012
    Location
    Philadelphia Metro, PA
    Posts
    5

    Default PIC18F25K22 Oscillator Settings

    Major brain moment here:

    I am using (newly) a PIC18F25K22. I have having some major difficulty for some reason finding the correct, easy to understand settings to use the internal osc with PBP, generally just basic settings, 4 Mhz is fine, 8, 10 15 whatever. Im currently not in the need of a specific speed.

    I do have timer and counter settings that are just not cooperating.


    Help!


    Thanks

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: PIC18F25K22 Oscillator Settings

    PBP's default configuration for the 18F25K22 uses the Internal Oscillator for the Primary Oscillator.
    So all you need to do is set the OSCCON register.

    OSCCON = %01010000 ; 4Mhz
    OSCCON = %01100000 ; 8Mhz
    OSCCON = %01110000 ; 16Mhz

    Or, if you enable the PLL with ...

    OSCTUNE.6 = 1 ; Enable 4x PLL

    Then ...

    OSCCON = %01010000 ; 16Mhz
    OSCCON = %01100000 ; 32Mhz
    OSCCON = %01110000 ; 64Mhz

    Make sure your DEFINE OSC matches.
    DT

  3. #3
    Join Date
    Oct 2012
    Location
    Philadelphia Metro, PA
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: PIC18F25K22 Oscillator Settings

    Thanks Darrel...


    But, I guess that was not the only reason I am not getting this to work:

    Take a look below. I have simplified what I am trying to do. Everything was working fine with my PICDEM PIC18 explorer board. But when I went off and built my own circuitry, nothing is happening.

    I have external pull ups on the inputs. They are being pulled low, but the "output" pin is not doing anything at all. I dont 'think' it's electrical per se, because I am grounding the input pin manually.

    What am I missing??

    and by the way, it is OSCCON = %01010000 it does not show up correct on the code snippet for some reason.

    Code:
    DEFINE OSC 4
    OSCCON = 010000  ; 4Mhz
    ADCON1 = 15  ' All pins digital
    
    STROBE var PORTA.0
    STROBEOUT var PORTB.0
    
    STROBEOUT = 0 'just making sure that it is off
    
    do
      IF STROBE = 0 THEN
      PAUSE 10
      STROBEOUT = 1
      ELSE
      STROBEOUT = 0
      ENDIF
    loop

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: PIC18F25K22 Oscillator Settings

    ADCON1 = 15 ... Sets the Positive and Negative Voltage references to invalid "Reserved" values.
    It does not configure "All Digital" like it might on other chips.
    For the 18F25K22, it should be ...
    Code:
    ANSELA = 0
    ANSELB = 0
    ANSELC = 0
    Your STROBEOUT pin hasn't been set to OUTPUT.
    Either set the TRIS bit, use the OUTPUT command, or use HIGH and LOW commands.
    DT

  5. #5
    Join Date
    Oct 2012
    Location
    Philadelphia Metro, PA
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: PIC18F25K22 Oscillator Settings

    It has been operating somewhat well now, but I have noticed that the delays and thresholds that I have put in place are not actually working properly, meaning that the actual delay is much greater than entered and expected. Any reason why this may be??

    Fo instance, if I declare a pause 3000, it seems to take almost 5 seconds, and 750 is almost 2 seconds.

  6. #6
    Join Date
    Sep 2016
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: PIC18F25K22 Oscillator Settings

    Hello,

    i am new to programming and am using a pic18f25k22 im trying to set it up to use an external 8mHz oscillator but from looking at the datasheet i am confused about how i do this any help would be appreciated

    thanks connor

Similar Threads

  1. PICs, CONFIGS and Oscillator Settings for Beginners
    By Demon in forum Code Examples
    Replies: 0
    Last Post: - 14th January 2012, 01:36
  2. 20MHZ External Oscillator Settings
    By ShaneMichael in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 27th October 2011, 01:44
  3. PIC18s and Oscillator settings
    By cc1984 in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 4th October 2011, 18:50
  4. Settings for internal oscillator
    By mradde in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 10th February 2009, 19:11

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