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

Change fuses

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



Joined: 22 Sep 2008
Posts: 6

View user's profile Send private message

Change fuses
PostPosted: Mon Dec 08, 2008 11:08 am     Reply with quote

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







PostPosted: Mon Dec 08, 2008 11:29 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Dec 11, 2008 4:25 am     Reply with quote

Thanks a lot!
That's much easier and it works now fine!
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