View previous topic :: View next topic |
Author |
Message |
Thom
Joined: 30 Jun 2011 Posts: 3 Location: France
|
18F45K80 switch oscillator |
Posted: Thu Jun 30, 2011 3:44 am |
|
|
Hello,
Can anybody help me?
I have a 18F45K80 with an external XO (16MHz) which have an enable pin.
I wish to switch to internal oscillator (31 KHz) and drive low the enable pin to shutdown the external oscillator.
Actually, the system have a huge consumption (200mA instead 60mA) when I execute this code:
Code: |
#use delay(internal=31KHZ)
setup_oscillator(OSC_31KHZ);
setup_oscillator(OSC_INTRC);
output_low(pin_B5); //shutdown the external oscillator
|
What fuses should be activated?
I have INTRC_LP and IESO.
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jul 01, 2011 12:14 pm |
|
|
Quote: | #use delay(internal=31KHZ)
setup_oscillator(OSC_31KHZ);
setup_oscillator(OSC_INTRC);
output_low(pin_B5); //shutdown the external oscillator
|
The setup_oscillator() function is not cumulative. You can't call it several
times sequentially and have the PIC retain each setting. The latest call to
the function overrides all previous calls.
If you need more help, then post a short but complete test program that
shows how you want to switch the oscillator speed. You could probably
do this program with no more than 10 lines in main(), including code to
blink an led to show the speed. Also post the #include for the PIC,
#fuses, #use delay(), etc. The program must compile. And most
important of all, it must be short. 10 lines max ! |
|
|
|