CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Changing osc frequency

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
championx



Joined: 28 Feb 2006
Posts: 151

View user's profile Send private message

Changing osc frequency
PostPosted: Mon Jun 06, 2016 9:24 am     Reply with quote

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!
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Jun 06, 2016 9:40 am     Reply with quote

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
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Jun 06, 2016 10:10 am     Reply with quote

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
championx



Joined: 28 Feb 2006
Posts: 151

View user's profile Send private message

PostPosted: Mon Jun 06, 2016 10:26 am     Reply with quote

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!
Ttelmah



Joined: 11 Mar 2010
Posts: 19338

View user's profile Send private message

PostPosted: Mon Jun 06, 2016 11:28 am     Reply with quote

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.
championx



Joined: 28 Feb 2006
Posts: 151

View user's profile Send private message

PostPosted: Mon Jun 06, 2016 1:19 pm     Reply with quote

Thanks! ill try this Ttelmah!

thanks for the help!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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