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.
Hope this helps someone.
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