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 CCS Technical Support

18f27j53 no write_configuration_memory available ??
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
spilz



Joined: 30 Jan 2012
Posts: 220

View user's profile Send private message

PostPosted: Mon Jun 22, 2015 5:36 am     Reply with quote

I tested your code and it works.

but this one doesn't :
Code:
void main()
{
   setup_oscillator(OSC_PLL_ON);
   flash();                                                   //48 seconds
   setup_oscillator(OSC_PLL_OFF);
   flash(); //48 seconds

   while(TRUE)
   {
      delay_cycles(1);
   }
}

and this one doesn't too :
Code:
void main()
{
   flash();  //5 seconds
   setup_oscillator(OSC_PLL_OFF);
   flash(); //48 seconds
   setup_oscillator(OSC_PLL_ON);
   flash();                                                   //48 seconds
   
   while(TRUE)
   {
      delay_cycles(1);
   }
}


it seems there is an issue with :
Code:
setup_oscillator(OSC_PLL_ON);


one other question, with PLL_OFF by software, does it really stop PLL running ?
I mean, as goal is to save power, I don't want this part still run even if it's not use.
Ttelmah



Joined: 11 Mar 2010
Posts: 20061

View user's profile Send private message

PostPosted: Mon Jun 22, 2015 8:50 am     Reply with quote

PLLEN, does disable the PLL when low. The clock diagram does not show this.

You should really never need to turn it on. It is on when you boot, so you just have to decide you are 'not' doing the bootload, and then switch to low power, otherwise leave it on.

However the problem is a chip erratum.
Look at item 2 in the errata sheet.

This enables it:
Code:

#BIT PLLEN=getenv("BIT:PLLEN")
#byte OSCCON=getenv("SFR:OSCCON")

   //to switch to the primary oscillator with PLL
   setup_oscillator(OSC_4MHz); //internal oscillator
   PLLEN=TRUE; //enable PLL
   OSCCON&=0xFC; //just switch oscillator type without changing PLL
spilz



Joined: 30 Jan 2012
Posts: 220

View user's profile Send private message

PostPosted: Tue Jun 23, 2015 5:28 am     Reply with quote

it works !

thanks for your help

I'm going to work on my bootloader now Smile

I see you use lot of "getenv", where do you find the names you use inside ? I don't see them in .h
Ttelmah



Joined: 11 Mar 2010
Posts: 20061

View user's profile Send private message

PostPosted: Tue Jun 23, 2015 7:07 am     Reply with quote

They are basically the register and bit names from the data sheet.

However if you have the IDE, select 'Tools', 'Device editor', then top right tab 'Registers', it opens a window with all the register and bit names for the current device.

In this particular case, the way that CCS changes the register (double byte wide writes to the two control registers), with the PLL selection for the primary oscillator, is exactly the scenario that causes the problem described in the erratum sheet. So you have to switch to the internal oscillator, then select the PLL enable without changing anything else in the register, and then change just the oscillator type....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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