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

    ASM
    ifndef __18F2221
    error "Wrong Processor Type"
    endif
    ENDASM

    DEFINE OSC 32
    DEFINE NO_CLRWDT 1
    DEFINE HSER_RCSTA 90H
    DEFINE HSER_TXSTA 24H
    DEFINE HSER_CLROERR 1
    DEFINE LOADER_USED 1 ' Tell compiler to relocate code for bootloader
    Define USE_LFSR 1



    TRISA = %11111111
    TRISB = %11111110
    TRISC = %10111111

    ADCON1 = $FF ' Start as all digital
    CMCON = %00000111 ' No Comparator used, turn it off
    ADCON2 = %10000110 ' Right Justify, /64
    OSCTUNE =%01000000 ' bit 6 to turn on the PLL
    OSCCON = %01110000 ' %11110000
    TopLoop:
    Toggle PORTB.0
    PAUSE 10
    GOTO TopLoop
    Charles Linquist

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    So you're only getting about 12.5Hz on PortB.0?

  3. #3
    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

  4. #4
    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!!!

  5. #5
    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

  6. #6
    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!!!

  7. #7
    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

  8. #8
    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

  9. #9
    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

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