|
|
View previous topic :: View next topic |
Author |
Message |
SLF
Joined: 22 Sep 2008 Posts: 6
|
Change fuses |
Posted: Mon Dec 08, 2008 11:08 am |
|
|
Hi together!
I need to change the fuses during my program between HSPLL and INTHS with a PIC 18F2550, because of the power consumption.
In HSPLL mode I need the USB in FullSpeed with a 20MHz Osc (PLL5) and CPUDIV1.
In INTHS I need only the Internal Oszillator with 2MHz.
I this possible to do?
I tested this code, but I think it doesn't work:
Switch to HSPLL:
Code: |
read_configuration_memory(0x300000,data,12);
bit_set(data[1],0);
bit_set(data[1],1);
bit_clear(data[1],2);
bit_set(data[1],3);
write_configuration_memory(data,0x300000,12);
setup_oscillator(OSC_2MHZ);
#asm
BSF 0x0F6F.2 // FSEN
#endasm
|
Switch to INTHS:
Code: |
read_configuration_memory(0x300000,data,12);
bit_set(data[1],0);
bit_set(data[1],1);
bit_clear(data[1],2);
bit_set(data[1],3);
write_configuration_memory(data,0x300000,12);
setup_oscillator(OSC_2MHZ);
#asm
BcF 0x0F6F.2// FSEN
#endasm
|
My compiler version is 4.073 |
|
|
Ttelmah Guest
|
|
Posted: Mon Dec 08, 2008 11:29 am |
|
|
Problem is that most fuses, are only read when the chip boots up.
Remember also, that the write life of the configuration memory, is relatively limited. Not a problem if you change a bit every few weeks, but a major problem if you change it more often....
Don't do this.
Use the chips oscillator switching ability instead. This is what it is there for...
Look at the options in the setup_oscillator command.
Best Wishes |
|
|
SLF
Joined: 22 Sep 2008 Posts: 6
|
|
Posted: Thu Dec 11, 2008 4:25 am |
|
|
Thanks a lot!
That's much easier and it works now fine! |
|
|
|
|
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
|