changing osc on the fly


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Posts
    15

    Question changing osc on the fly

    hi all,

    I need to change the clock speed on the fly or dinamicly in the code ,

    i am using pic18f4550 and i need to switch from 48mhz to 24 or even 4 mhz to drop power consumtion in certin setuaion, i can change config bits, but i am using the uart (hserin) ,hserout, also sound and need them to adaopt to the new clock

    any ideas ?

    thank you

  2. #2
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    For the uart, just change baudcon (or its equivelant) to manually adjust the baud rates to maintain your clock speed. There are easy to read charts in the datasheets.

    In my apps, I set up a sub for each clock speed I run at, and then gosub the appropriate sub each time I need to change clock speed. Each subroutine sets the osccon, baudcon, and any other delay related variables so all of my routines behave the same regardless of the actual running speed.

    For timed delays, you will have to either adjust the parameter, or make your own delay routines that use your own parameters. (For instance, instead of the built in delayms you would use a gosub DelayCorrectedms, which loops and calls delayus with an adjusted time...keeping in mind the added overhead of the basic code.)

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


    Did you find this post helpful? Yes | No

    Default

    I may be wrong on this but...

    Power consumption is relative to voltage. Clock speed is relative to voltage.
    Faster the clock, higher the voltage.

    But with this type of PIC it will run at 2 volts with a 4MHz external.
    So, using the PLL the PIC can "virtually" run at 48MHz on 2 volts and not consume extra power.

    ???

    I run this PIC at 3.3 volts and 48MHz but I have not measured the amps...
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    I may be wrong on this but...

    Power consumption is relative to voltage. Clock speed is relative to voltage.
    Faster the clock, higher the voltage.

    But with this type of PIC it will run at 2 volts with a 4MHz external.
    So, using the PLL the PIC can "virtually" run at 48MHz on 2 volts and not consume extra power.

    ???

    I run this PIC at 3.3 volts and 48MHz but I have not measured the amps...
    That is all true... but you will save even more power by putting the pic to sleep. A a high speed pic that is sleeping most of the time will draw less power than a 4mhz pic awake all the time.

  5. #5
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    ....Clock speed is relative to voltage.
    Not quite. There are minimum voltages required to run at specific frequencies but there is not a direct relationship between the 2.



    Quote Originally Posted by mackrackit View Post
    ....Power consumption is relative to voltage.

    But with this type of PIC it will run at 2 volts with a 4MHz external.
    So, using the PLL the PIC can "virtually" run at 48MHz on 2 volts and not consume extra power.
    You cannot run it at 48Mhz with a 2V supply. With a PIC18F4550 supply current can range from 0.8mA (4MHz INTRC, 2.0V) to as high as 50mA (48MHz EC, 5.0V), a range of more than 62:1 - see section 28.2 DC Characteristics: Power-Down and Supply Current of the data sheet.

    Using one of the Power Managed (idle/sleep) modes is the proper way to go. See Section 3.0.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rmteo View Post
    Not quite. There are minimum voltages required to run at specific frequencies but there is not a direct relationship between the 2.
    OK. Not a direct relationship. I should have said clock speed and minimum voltatge.
    You cannot run it at 48Mhz with a 2V supply. With a PIC18F4550 supply current can range from 0.8mA (4MHz INTRC, 2.0V) to as high as 50mA (48MHz EC, 5.0V), a range of more than 62:1 - see section 28.2 DC Characteristics: Power-Down and Supply Current of the data sheet.

    Using one of the Power Managed (idle/sleep) modes is the proper way to go. See Section 3.0.
    Maybe not at 2 volts, but 2.5 is doable. Using the PICKIT2 for a PS, only goes down to 2.5. So I can not verify the 2 volts right now...
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    ...Maybe not at 2 volts, but 2.5 is doable. Using the PICKIT2 for a PS, only goes down to 2.5. So I can not verify the 2 volts right now...
    It is poor engineering practice to operate a device outside of the manufacturer's specs - take a look at the graph above where it shows that the minimum voltage is 4.2V for frequencies >25Mhz.

Similar Threads

  1. Define osc 1
    By ronsimpson in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st October 2009, 06:35
  2. Changing bits in a byte for multiple output
    By tazntex in forum Serial
    Replies: 3
    Last Post: - 11th August 2008, 19:10
  3. Replies: 4
    Last Post: - 16th May 2008, 14:35
  4. Changing declared variables names on the fly
    By jessey in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th December 2006, 06:34
  5. Mode changing on the fly
    By Angus Anderson in forum GSM
    Replies: 1
    Last Post: - 28th November 2006, 08:58

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