18F4520 and internal osc & PLL


Closed Thread
Results 1 to 8 of 8

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Change OSCCON = $72 to OSCCON = $70 (%01110000).
    Regards,

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

  2. #2
    pwhitt's Avatar
    pwhitt Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Bruce,

    Thanks very much. I actually got the same advice from PIC Basic support - although the $72 value was given to me by support earlier, and matched teh value I was using. This does indeed fix it - I see now that the PIC is configured to use the "main oscillator" rather than the internal - but could you please explain why? I was assuming the internal oscillator was everything internal and the main oscillator was an external crystal or RC.

    To avoid any confusion to those that may notice - the first OSCCON value I posted had OSCCON=$7F. This was copied/pasted from a file in which I was thoughtlessly monkeying with the values attempting to fix it.

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


    Did you find this post helpful? Yes | No

    Default

    The primary oscillators include the External Crystal and Resonator modes, the
    External RC modes, the External Clock modes and the internal oscillator block.

    You set the "primary" oscillator with FOSC3:FOSC0 configuration bits - so with
    the internal oscillator block set in CONFIG1H, and 8MHz or 4MHz selected in
    OSCCON, you need System Clock Select bits SCS1:SCS0 set for "primary" for
    PLL to work.

    The PLL is available only when it's configured to use the internal oscillator
    block as its "primary" clock source (FOSC3:FOSC0 = 1001 or 1000).

    It's not exactly hit-you-in-the-face clear from looking at the datasheet, but
    that's the only way to turn on PLL when using the internal osc.
    Regards,

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

  4. #4
    pwhitt's Avatar
    pwhitt Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks so much for clearing that up Bruce - excellect.

  5. #5
    juliogbox's Avatar
    juliogbox Guest


    Did you find this post helpful? Yes | No

    Default Bug in MPLAB?

    I had exactly the same problem with PIC18F1330. But I could fix it using the Bruce advice:
    movlw B'0111000'
    movwf OSCCON, A

    But there is a strange behavior of the MPLAB-SIM. If I do this:
    movlw B'0111011'
    movwf OSCCON, A

    The simulator do not write the two lower bits, as you can see in this image (click to enlarge):



    But in the hardware the two bits are written, that's the reason because the PLL hadn't worked in my prototype.

Similar Threads

  1. OSCON setting for 18F4520
    By Dennis in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 29th November 2009, 16:18
  2. blink.bas for 18f4520 for newbie - HELP
    By Dennis in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th November 2009, 19:45
  3. Comparators on 18F4520
    By RacerX10 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th August 2009, 00:33

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