Can't get 18F2221 PLL to run with INTOSC


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Yes, and as I mentioned, I'm getting 2MHz out of OSC2. Since that is a /4 , the oscillator is in fact running 8. Only the PLL isn't working properly.
    Charles Linquist

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    Yes, and as I mentioned, I'm getting 2MHz out of OSC2. Since that is a /4 , the oscillator is in fact running 8. Only the PLL isn't working properly.
    I'm guessing here...the datasheet is a bit convoluted and jumps back and forth a bit...
    2Mhz from OSC2 is right isn't it? OSC2 is FOsc/4, FOsc/4 is 8Mhz/4... System clock isn't FOsc in this case, it's the actual clock speed before the PLL...
    Try that test program with
    main:
    High portb.0
    pause 500
    low portb.0
    pause 500
    goto main
    .......just to see what happens. Should be one flash per second of course at 32Mhz. One flash every 4 seconds would certainly mean 8Mhz.


    Also, I'm wondering if the bootloader is messing with your bits for you and shutting off your PLL!!!

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Have you tried OSCCON = %01110010?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Have you tried OSCCON = %01110010?
    Don't I feel like a dipstick! Internal OSC block was never selected in the first place!!!

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


    Did you find this post helpful? Yes | No

    Default

    Also, try putting the OSCCON statement before the OSCTUNE.

    Quote Originally Posted by datasheet
    Additionally,
    the PLL will only function when the selected output frequency
    is either 4 MHz or 8 MHz (OSCCON<6:4> = 111
    or 110). If both of these conditions are not met, the PLL
    is disabled and the PLLEN bit remains clear (writes are
    ignored).
    <br>
    DT

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Yep I think DT just nailed it. Might be holding it off until it's in the right mode for the switch.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Confirmed -

    Darrel, you were right again. Now that I switch to 8MHz BEFORE I enable the PLL, it
    works as expected.

    Thanks!
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Thumbs up

    S-W-W-EET!
    <br>
    DT

  9. #9
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    And one last "Gotcha" that I forgot to mention earlier - bits 0 and 1 of
    OSCCON *MUST* be set to "00".

    Even though you are running off the Internal Oscillator Block, if you
    enable the PLL, you have to configure for PRIMARY OSCILLATOR.

    Summary -

    To run off the Internal oscillator and use the 4X PLL:

    Set OSCCON bits 6 through 4 for either 8MHz (111) or 4MHz (110) and OSCCON
    bits 1 and 0 for PRIMARY OSCILLATOR (00)

    Set OSCTUNE.6 = 1 to enable the PLL.

    In that order!
    Charles Linquist

Similar Threads

  1. Program compiles and writes but can't run
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 23rd March 2009, 04:38
  2. 18F4520 and internal osc & PLL
    By pwhitt in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 15th September 2008, 06:38
  3. 16F628 and LMX2306 PLL loading.. help
    By kessral in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 11th June 2008, 17:03
  4. Pll?
    By atwoz in forum General
    Replies: 2
    Last Post: - 19th December 2007, 10:20
  5. Cannot compile for 40MHz 4 x pll
    By passion1 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 21st October 2007, 17:50

Members who have read this thread : 0

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