Hi All,

I am new to using freescale microcontrollers and would appreciate any help I can get. I have got everything I need for my project working except the phased locked loop(PLL). The controller seem to want to stay working at a 2Mhz bus speed. I a clocking off a 8Mhz x-tal and want the bus frequency also at 8Mhz. Below is the register setting I have put into codewarrior.

PCTL_PLLIE = 0;//turns off PLL interupt

PCTL_PLLON = 0;//turn off PLL so can set P,R,N,E and L

PCTL_PRE0 = 0;//sets P to 0

PCTL_PRE1 = 0;//sets P to 0

PCTL_VPR0 = 0;//sets E to 2

PCTL_VPR1 = 1;//sets E to 2

PMSH_MUL11 = 0;//sets N to 4

PMSH_MUL10 = 0;//sets N to 4

PMSH_MUL9 = 0;//sets N to 4

PMSH_MUL8 = 0;//sets N to 4

PMSL_MUL7 = 0;//sets N to 4

PMSL_MUL6 = 0;//sets N to 4

PMSL_MUL5 = 0;//sets N to 4

PMSL_MUL4 = 0;//sets N to 4

PMSL_MUL3 = 0;//sets N to 4

PMSL_MUL2 = 1;//sets N to 4

PMSL_MUL1 = 0;//sets N to 4

PMSL_MUL0 = 0;//sets N to 4

PMRS_VRS7 = 0;//sets L to 64

PMRS_VRS6 = 1;//sets L to 64

PMRS_VRS5 = 0;//sets L to 64

PMRS_VRS4 = 0;//sets L to 64

PMRS_VRS3 = 0;//sets L to 64

PMRS_VRS2 = 0;//sets L to 64

PMRS_VRS1 = 0;//sets L to 64

PMRS_VRS0 = 0;//sets L to 64

PMDS_RDS3 = 0;//sets R to 1

PMDS_RDS2 = 0;//sets R to 1

PMDS_RDS1 = 0;//sets R to 1

PMDS_RDS0 = 1;//sets R to 1

PCTL_PLLON = 1;//turn on PLL

PCTL_BCS = 1;//set CGMPCLK to source CGMOUT

PBWC_AUTO = 1;//Automatic bandwidth control

while(PBWC_LOCK == 0){

}

PCTL_PLLON = 0;//turn off PLL so can set P,R,N,E and L

PCTL_PRE0 = 0;//sets P to 0

PCTL_PRE1 = 0;//sets P to 0

PCTL_VPR0 = 0;//sets E to 2

PCTL_VPR1 = 1;//sets E to 2

PMSH_MUL11 = 0;//sets N to 4

PMSH_MUL10 = 0;//sets N to 4

PMSH_MUL9 = 0;//sets N to 4

PMSH_MUL8 = 0;//sets N to 4

PMSL_MUL7 = 0;//sets N to 4

PMSL_MUL6 = 0;//sets N to 4

PMSL_MUL5 = 0;//sets N to 4

PMSL_MUL4 = 0;//sets N to 4

PMSL_MUL3 = 0;//sets N to 4

PMSL_MUL2 = 1;//sets N to 4

PMSL_MUL1 = 0;//sets N to 4

PMSL_MUL0 = 0;//sets N to 4

PMRS_VRS7 = 0;//sets L to 64

PMRS_VRS6 = 1;//sets L to 64

PMRS_VRS5 = 0;//sets L to 64

PMRS_VRS4 = 0;//sets L to 64

PMRS_VRS3 = 0;//sets L to 64

PMRS_VRS2 = 0;//sets L to 64

PMRS_VRS1 = 0;//sets L to 64

PMRS_VRS0 = 0;//sets L to 64

PMDS_RDS3 = 0;//sets R to 1

PMDS_RDS2 = 0;//sets R to 1

PMDS_RDS1 = 0;//sets R to 1

PMDS_RDS0 = 1;//sets R to 1

PCTL_PLLON = 1;//turn on PLL

PCTL_BCS = 1;//set CGMPCLK to source CGMOUT

PBWC_AUTO = 1;//Automatic bandwidth control

while(PBWC_LOCK == 0){

}

thanks

dan

Accessing those registers one-bit at a time is quite tedious. I would suggest writing them as bytes, at least up until it is time to set the PLLON bit, followed by the BCS bit.

In particular, I would set the AUTO bit prior to enabling PLLON. Setting the AUTO bit as you do with the C statement will generate BSET instruction, which is a read-modify-write operation. If the LOCK bit happens to be set when you do this, you will end up writing a 1 to the LOCK bit, which is a no-no. From page 91 of the data sheet, here is part of the description of the LOCK bit::

Although I program in assembly language, here is my code for the PLL, so you have an idea for the order I do it. It may not be totally correct, but it has worked for me.

Hope that helps