View previous topic :: View next topic |
Author |
Message |
championx
Joined: 28 Feb 2006 Posts: 151
|
Changing osc frequency |
Posted: Mon Jun 06, 2016 9:24 am |
|
|
Hi guys, how are you?
I'm trying to change the frequency on a battery powered circuit. The idea is to lower the current consumption when the battery get to a certain level.
I managed to change the freq using the setup_oscillator function, but, then the UARTS and timers doesn't work as defined... is there a way to reconfigure the timers and uart after using the setup_oscillator function to use the new freq?
thanks! |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Mon Jun 06, 2016 9:40 am |
|
|
1) try putting a fresh #use RS232 compiler instruction line after each change of Fosc setup you do.
2) DO NOT USE delay_ms() etc at all as it will go very wrong for you
instead user timers for delays and thus
3) Also be aware you will need to reset you timer setups if using them too - based on any frequency you choose.
4) experiment with care |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9176 Location: Greensville,Ontario
|
|
Posted: Mon Jun 06, 2016 10:10 am |
|
|
this...
Quote: |
I'm trying to change the frequency on a battery powered circuit. The idea is to lower the current consumption when the battery get to a certain level. |
May not do what you think it will ! There's a Microchip APnote abut battery powered device, batteries, consumptions, etc. It's actually a 'must read'.
While a lower frequency does reduce power, you have to calculate the startup power needed to get 'up to operating speed'. As well many 'peripherals' need time which costs you power.
For a lot of battery applications, simply using a more powerful battery is a quick, easy, cost effective solution just be sure about 'operating temperatures' when dealing with battery operated devices. The colder it get, the battery will have far LESS power available !!
Jay |
|
![](templates/subSilver/images/spacer.gif) |
championx
Joined: 28 Feb 2006 Posts: 151
|
|
Posted: Mon Jun 06, 2016 10:26 am |
|
|
Hi! thanks for your answers! I will try it.
temtronic, im using a 24EP512GU810, and for every MHZ it consumes 1mA, so changing from 160Mhz to 8Mhz it really a very big jump on consumption.
If I were using a pic 18F i dont bother on changing the freq.
thabnks! |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19375
|
|
Posted: Mon Jun 06, 2016 11:28 am |
|
|
The way to handle the RS232, is to cheat!...
Generate a macro to set_uart_speed, something like:
Code: |
#define STANDARD_SPEED 1
#define SLOW_SPEED 20
int16 speed_factor=STANDARD_SPEED;
#define UART_SPEED(x) set_uart_speed(x*speed_factor)
//Then in your code, when you change to slow speed:
speed_factor=SLOW_SPEED;
UART_SPEED(9600); //or whatever baud you want
//and when you go back to fast
speed_factor=STANDARD_SPEED;
UART_SPEED(9600);
|
You can also use the factor to handle delays (/factor for this).
If working with 'constant' delays, baud rates etc., the multiplications and divisions are done at compile time, so it gives easy and efficient changing. |
|
![](templates/subSilver/images/spacer.gif) |
championx
Joined: 28 Feb 2006 Posts: 151
|
|
Posted: Mon Jun 06, 2016 1:19 pm |
|
|
Thanks! ill try this Ttelmah!
thanks for the help! |
|
![](templates/subSilver/images/spacer.gif) |
|