pic18f25k22 clock


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2016
    Posts
    5

    Default pic18f25k22 clock

    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

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: pic18f25k22 clock

    What do you want the resultant PIC internal clock to be?
    George

  3. #3
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: pic18f25k22 clock

    Page 33 of the datasheet shows you how to connect an external resonator or crystal to RA6 and RA7. 22pf or 33pf ceramic capacitors are typical values used.

    However as Towlerg stated, this is not the only thing to consider as the PIC has various modes of oscillation, which effectively can multiply the resonator / crystal frequency by factors up to four fold ( eg using an 8Mhz crystal and an HS_PLL setting it can run at 32 Mhz). If you can provide more information as to exactly what speed you want to run the PIC at then I'm sure you'll get more help and guidance.

  4. #4
    Join Date
    Sep 2016
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: pic18f25k22 clock

    thanks for your reply i have an 8mHz crystal attached to RA6 and RA7 with a .22pF cap both sides. i think ive found the code within mplab ide where it auto generates the code but im now struggling to find out how to set the i/o ports to outputs and just get the pic working in general.... STRESSFUL!!!!

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: pic18f25k22 clock

    Generally to set a port to output you write a 0 to the relevant TRISx (where x is the port letter). Even better from the manual -
    5.48 OUTPUT
    OUTPUT Pin
    Make the specified Pin an output. Pin may be a constant, 0 - 15, or a variable that contains a number 0 - 15 (e.g. B0) or a pin name (e.g. PORTA.0).
    OUTPUT 0 ' Make Pin0 an output
    OUTPUT PORTA.0 ' Make PORTA, pin 0 an output
    Alternatively, the pin may be set to an using direct register access:
    TRISB.0 = 0 ' Set PORTB, pin 0 to an output
    All of the pins on a port may be set to outputs by setting the entire TRIS register at once:
    TRISB = %00000000 ' Set all of PORTB to outputs
    George

  6. #6
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: pic18f25k22 clock

    Quote Originally Posted by connortop View Post
    thanks for your reply i have an 8mHz crystal attached to RA6 and RA7 with a .22pF cap both sides. i think ive found the code within mplab ide where it auto generates the code but im now struggling to find out how to set the i/o ports to outputs and just get the pic working in general.... STRESSFUL!!!!
    Post up your code as you have it and I'm sure we'll get you sorted

Similar Threads

  1. PIC18F25K22 Oscillator Settings
    By electromark in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th September 2016, 08:20
  2. PIC18F25k22 configuration - I/O problem
    By DaTiNs in forum Code Examples
    Replies: 0
    Last Post: - 29th November 2012, 13:19
  3. Trying to generate 2MHz PWM with PIC18F25K22
    By TimHeff in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th July 2012, 05:08
  4. PIC18f25k22 help with OSC configs
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th February 2012, 18:23
  5. serial communication problem with PIC18F25K22
    By harryweb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th April 2011, 10:26

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