eoinoc
Joined: 30 Apr 2009 Posts: 16
|
Clock Switch Issue |
Posted: Mon Nov 15, 2010 11:43 am |
|
|
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
|
|
Posted: Mon Nov 15, 2010 2:23 pm |
|
|
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. |
|