|
|
View previous topic :: View next topic |
Author |
Message |
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
How to drop down the oscillator frequency? |
Posted: Mon Jul 16, 2012 11:35 pm |
|
|
Greetings! I'm using PIC18F4431 at 40MHz (10MHz crystal and PLL). I want to drop down this frequency to let`s say 5-10kHz. Is there a way to do this without exchanging the crystal??
Thanks! |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1612 Location: Central Illinois, USA
|
|
Posted: Mon Jul 16, 2012 11:47 pm |
|
|
Unless you build in circuitry to switch down the crystal -- not really.
Now, some PIC's (not sure if the 18F4431 supports this) will allow you to turn on/off the PLL in software.
This results in a speed switch (and thus a power reduction).
Those same PIC's also usually allow the ability to switch to the internal RC oscillator (or TIMER1) -- which run at like 32KHz.
Which further really cranks down the speed/power.
Keep in mind, timing delays get all messed up if you don't code to cope with the speed change...
As for switching out crystals, it could be done -- but you'd need extra hardware to switch out the crystals to do it.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19485
|
|
Posted: Tue Jul 17, 2012 1:13 am |
|
|
On this chip, you can switch to the internal oscillator at 31KHz, under software control:
Code: |
setup_oscillatator(OSC_31KHz|OSC_INTRC); ///To switch down
setup_oscillator(OSC_NORMAL); //To switch back up to the default oscillator
|
Seriously though, there are a lot of things to consider:
1) Obviously, things like serial ports etc., will no longer work, unless you reprogram the baud rates to match, and only quite slow rates can be used with such a slow clock.
2) It takes significant _time_ to switch back to the master oscillator an let it stabilise. The setup_oscillator call returns 'OSC_STATE_STABLE', and this should be tested, before you use _anything_ involving times.
3) Power saving, may be less than you expect. The biggest savings on the PIC, are ensuring that pins are not allowed to float, the external regulator (ir is typical to find people complaining that the chip draws more than they expect, then find out it is the regulator....). 1MHz, typically only draws under 0.5mA, while 33Khz, is still over 1/3rd of this. There is a law of 'diminishing returns' as you go slower. If you want low power consider if you can put the chip to sleep for some time instead?.
4) Remember the internal oscillator is not terribly accurate, but has the advantage of drawing less power than the external crystal. Typically draws about 1/4 what an external crystal requires. If great accuracy is not needed, and you can handle the code you want at a slightly slower rate, then using the internal oscillator at 8MHz, and not switching, may be the 'better' route.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|