OSCON setting for 18F4520


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Thanks for the correction.
    The data sheet for the 18F4550 does not have the sections you referred to.
    DOH!!!

    Time to check my glasses...
    Dave
    Always wear safety glasses while programming.

  2. #2


    Did you find this post helpful? Yes | No

    Default so to clarify ...

    First of all thanks all of you for your replies, thoughts and guidance :-)

    All postings have raised a few questions though ...

    Code:
     DEFINE OSC 8
    OSCCON=%01110000
    or
    DEFINE OSC 4
    OSCCON=%01100000
    
    OSCTUNE.6 = 1 'PLL 4x
    So far we know ..according to the datasheet that PLL is only available if we run at 4MHz or 8MHz and the PLL bit is enabled.

    With this in mind, if your desired frequency is either 4 or 8 MHz , you probably want to make sure that OSCTUNE.6=0 since this would disable the PLL setting.
    So the above code settings for 4 or 8MHz would be as follows
    Code:
     DEFINE OSC 8
    OSCCON=%01110000
    or
    DEFINE OSC 4
    OSCCON=%01100000
    
    OSCTUNE.6 = 0 'PLL Multiplier disabled
    And thats as per this in the datasheet
    Unlike HSPLL mode, the PLL is controlled through
    software. The control bit, PLLEN (OSCTUNE<6>), is
    used to enable or disable its operation.
    The PLL is available when the device is configured to
    use the internal oscillator block as its primary clock
    source (FOSC3:FOSC0 = 1001 or 1000). Additionally,
    the PLL will only function when the selected output fre-
    quency is either 4MHz or 8MHz (OSCCON<6:4> = 111
    or 110). If both of these conditions are not met, the PLL
    s disabled.
    The PLLEN control bit is only functional in those inter-
    nal oscillator modes where the PLL is available. In all
    other modes, it is forced to ‘0’ and is effectively
    unavailable.
    Am I correct ?
    Kind regards
    Dennis

  3. #3


    Did you find this post helpful? Yes | No

    Default hmm...?

    Just another thought..

    Can you achieve 20MHz then ?

    Can the PLL multiplier be altered to achieve 20MHz maybe ?

    Dennis

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    The PLL multiplyer will multiply x4 whatever your OSCILLATOR is running at. There are no other options... it's either x4 or OFF.

    You need a 5MHz Crystal or Resonator if you want 20MHz using the PLL Multiplier.

    The Internal Oscillator does not have 5MHz as one of it's selectable options (neither does it have 20MHz).

    So if you WANT 20MHz, you'll need a 20MHz Xtal or Resonator, use HS Mode and have the PLL multiplier OFF (or 5MHz Xtal or Resonator, HS Mode and have the PLL multiplyer ON).

    Section 2, Datasheet DS39631A explains it in great detail (for the 18F4520 chip) which you said you were using at the start of this thread.

  5. #5


    Did you find this post helpful? Yes | No

    Default got it !

    Thank Melanie and everyone else who replied to this thread !

    It is all CRYSTAL CLEAR now !!
    :-)

    Thank a million

Similar Threads

  1. PICKit2 - warning about configuration words
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 4th August 2009, 15:01
  2. PWM setting PIC16F887
    By Gevo in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 12th June 2008, 08:24
  3. code size VS speed optimization setting?
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th April 2008, 15:38
  4. Setting up the oscillator
    By J_norrie in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 2nd October 2007, 15:53
  5. Help with setting adcon1 for 16f877
    By jessey in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 16th August 2005, 12:13

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