PLL Question

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

PLL Question

4,698件の閲覧回数
lssuer
Contributor I
I am using the MC9S12DP256B microcontroller and I have written a routine to utilize the phase loop lock feature. Every time I run the debugger in codewarrior my program goes into the clock monitor fail reset.

The code that I have written is as follows:

void SetClkSpeed20(void)
{
//multiply 4MHz by 2 by 5/1 to get 40MHz for the PLL
//or a bus clk of 20 MHz
SYNR=4;//+1
REFDV=0;//+1
while (!(CRGFLG_LOCK)) ;//wait for PLL lock
CLKSEL_PLLSEL=1; //engage PLL
}

I am also using SPI in this program, is there an issue with using both SPI and PLL that would cause the clock monitor fail reset or could I be missing something in my PLL routine that is causing the clock monitor fail reset. Any advice or insight into this interrupt or problem would be appreciated.

Thanks,
Lssuer
ラベル(1)
0 件の賞賛
返信
4 返答(返信)

927件の閲覧回数
pittbull
Contributor III
Hi Issuer,
I'm not sure if this happens if your SYNR or REFDV values are wrong but I had a similar problem when the oscillator was down. If the osc. is not running, the MCU uses 'self-clocking' and thus you can't activate the PLL.
0 件の賞賛
返信

927件の閲覧回数
MO_84
Contributor III

I had a similar problem with the Dragon 12 Plus board.

When you switch from LOAD mode to RUN mode, the clock frequency changes from 24MHz to 4MHz. This was messing up a lot of my Calculations. I used the PLL and it works fine now.

 

PLLCLK = 8*2*6/2 = 48MHz
The bus speed = PLLCLK / 2 = 24 MHz

 

Here is code. Its very similar to the ones above:

 

void Set_Clock(void)
{
    CLKSEL &= 0x7F;
    PLLCTL |= 0x40;
    SYNR  = 0x05;
    REFDV = 0x01;
    while(!(0x08 & CRGFLG));
    CLKSEL |= 0x80;

 

You can also find a description of what all the above registers do at the link beow under the Clock and Reset Generator section.

 

http://cache.freescale.com/files/microcontrollers/doc/data_sheet/MC9S12DP256.pdf?fsrch=1&WT_TYPE=Dat...

 

 

Hope this helps someone.

0 件の賞賛
返信

927件の閲覧回数
domi2c
Contributor I

Hello,

I'm also using a MC9S12DP256B on Dragon12 and MiniDragon. The two have a bus speed of 8MHz with a cristal at 16 MHz. And I've had to create a little function to run my boards at 24MHz when not using D-Bug12.

I'm not using codewarrior but the ICC12 compiler, and here is my function and it works fine :

void set_pll(void)

{

ClearBit(CLKSEL,0x80);

SetBit(PLLCTL,0x40);

SYNR = 0x05;

REFDV = 0x03;

do

{

;

} while (TestBit(CRGFLG,0x08) == 0);

SetBit(CLKSEL,0x80);

}

I think the 2 first and bold lines are missing in your code.

 

hope this helps

Jean Claude

0 件の賞賛
返信

927件の閲覧回数
gautier
Contributor II
hello,
 
I have the same problembut with SCI port.
After some research I have found the EB614/D
it's detail that some componant have a problem.
look at this bulletin, perhaps it can help you.
 
it's in attachement part.
 
excuse me for spelling mistake I'm French.
 
good luck!
 
Message Edited by t.dowe on 2009-10-21 12:20 AM
0 件の賞賛
返信