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

Clock Switch Issue

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



Joined: 30 Apr 2009
Posts: 16

View user's profile Send private message

Clock Switch Issue
PostPosted: Mon Nov 15, 2010 11:43 am     Reply with quote

Hi all,

I have a problem with my clock switching operation and switching on the internal PLL for the PIC24FJ64GB002.
Code:

#define switch_16mips{\ #asm \ mov #0x0743,w1\ #endasm \ #asm \ mov.b x,w0 \ #endasm \ #asm \ mov #0x78,w2 \ #endasm \ #asm \ mov #0x9a,w3 \ #endasm \ #asm \ mov.b w2,[w1] \ #endasm \ #asm \ mov.b w3,[w1] \ #endasm \ #asm \ mov.b w0,[w1] \ #endasm \ #asm \ mov #0x742,w1\ #endasm \ #asm \ mov.b y,w0 \ #endasm \ #asm \ mov #0x46,w2 \ #endasm \ #asm \ mov #0x57,w3 \ #endasm \ #asm \ mov.b w2,[w1] \ #endasm \ #asm \ mov.b w3,[w1] \ #endasm \  oswen=1; while(oswen);}
#define switch_1MIPS{\  #asm \ mov #0x0743,w1\ #endasm \ #asm \ mov.b x,w0 \ #endasm \ #asm \ mov #0x78,w2 \ #endasm \ #asm \ mov #0x9a,w3 \ #endasm \ #asm \ mov.b w2,[w1] \ #endasm \ #asm \ mov.b w3,[w1] \ #endasm \ #asm \ mov.b w0,[w1] \ #endasm \ #asm \ mov #0x742,w1\ #endasm \ #asm \ mov.b y,w0 \ #endasm \ #asm \ mov #0x46,w2 \ #endasm \ #asm \ mov #0x57,w3 \ #endasm \ #asm \ mov.b w2,[w1] \ #endasm \ #asm \ mov.b w3,[w1] \ #endasm \ oswen=1;  while(oswen);}


while(true)
{
int8 x,y;

x=oscconhigh;
bit_set(x,0); // selects new source to be FRC PLL with Post
bit_clear(x,1);
bit_clear(x,2);

y=oscconlow;
 y=oscconlow|0x03;

change_div_16mips;
switch_16mips; // puts x into oscconhigh and y into oscconlow


x=oscconhigh; // selects new source to be FRC with Post
bit_set(x,0);
bit_set(x,1);
bit_set(x,2);

y=oscconlow;
y=oscconlow|0x03; 

change_div_1mips;
switch_1mips;// puts x into oscconhigh and y into oscconlow

}

The problem is the following, when I set a breakpoint before I attempt to do a clock switch and read back fro OSCCON I see that the current oscillator selection source is FRC even though I set the fuse for FNOSC to be FRC with PLL and Postscaler.
The clock switch to FRC with postscaler works and I read back 0x7702 from OSSCON, which means current Osc source is FRC with Postscaler.

Any ideas why I cant switch on the PLL for the FRC?

Ps for the macro it may be hard to read, but its the unlock method from the Microchip datasheet.
eoinoc



Joined: 30 Apr 2009
Posts: 16

View user's profile Send private message

PostPosted: Mon Nov 15, 2010 2:23 pm     Reply with quote

Just a quick update on this issue

I noticed that when I disable the TwoSpeedStartUp fuse the processor will not run when I select the FRC with PLL as the initial oscillator in the fuses, if i enable the TwoSpeedStartUp fuse the processor will run because it appears to try to enable the PLL but then switches back the FRC because it appears the FRC PLL is failing.

If I select FRC on its own or FRC with Postscale and disable IESO it will also run, problem only occurs when FRC PLL is the initial choice in the fuses.
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