Can i change the bus clock of MC9S12XDT512 to 0.5MHz

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can i change the bus clock of MC9S12XDT512 to 0.5MHz

2,817 Views
changebusclock
Contributor I

i want to communicate using 5baud using SCI.

I am using  Demo version of MC9S12XDT512 controller in our lab(TIFAC-CORE, VIT University)

Can anyone suggest me what to do.

I already tried setting registers like REFDV and PLLSEL bit . But when i set the PLLSEL flag, LOCK And TRACE flags are cleared automatically, nullifying my initiation. 

Labels (1)
Tags (1)
0 Kudos
Reply
7 Replies

965 Views
kef
Specialist I

Using PLL to reduce bus clock may work. But I think you need to recalculate and change PLL filter components. Filters may require few orders larger capacitances. It could be simpler to change crystal frequency.

 

LOCK and TRACE clear not due to setting PLLSEL, but because lock is not stable. With bad filter LOCK and TRACE can keep switching on/off continuously. To check if PLL doesn't loose lock, after setting up REFDV and SYNR with LOCK==1, you should clear LOCKIF bit by writing one to it. Then after some time check if LOCKIF is still cleared. If it's one, then PLL has lost the lock at least once.

0 Kudos
Reply

965 Views
changebusclock
Contributor I

Thanks for your reply.

Is this what you suggested me to do?

REFDV=0x07;

SYNR=0x00;

CRGFLG_LOCKIF=1;

CLKSEL_PLLSEL=1; 

}

 

Before running the above statements , register values are

REFDV=0;

SYNR=0;

CRGFLG IS 28(unsigned char indicating LOCK=1 and TRACK=1 and LOCKIF=1)

CLKSEL IS 0(unsigned char)

 

After executing the statements above , register values are

REFDV=7(unsigned char)

SYNR=0(unsigned char)

CRGFLG IS 0(unsigned char)

CLKSEL IS 0(unsigned char)

 

I think i am not able to change PLLCLK. WHAT TO DO 

0 Kudos
Reply

965 Views
kef
Specialist I

REFDV=0x07;    // I guess you are using 4MHz crystal.

SYNR=0x00;

 

Wait here until LOCK==1.

 

 

CRGFLG_LOCKIF=1; // Clear LOCKIF (but keep in mind that CRGFLG_LOCKIF=1 clears not only LOCKIF, but also RTIF, PORF and LVRF)

 

Stay here for a while, at least for few seconds. Then check if LOCKIF still reads as 0. If LOCKIF is cleared and LOCK is set, then PLL seems being stable.

CLKSEL_PLLSEL=1; 

}

 

Before running the above statements , register values are

REFDV=0;

SYNR=0;

CRGFLG IS 28(unsigned char indicating LOCK=1 and TRACK=1 and LOCKIF=1)

CLKSEL IS 0(unsigned char)

 

After executing the statements above , register values are

REFDV=7(unsigned char)

SYNR=0(unsigned char)

CRGFLG IS 0(unsigned char)

CLKSEL IS 0(unsigned char)

 

 

It takes some time PLL to lock. After writing to REFDV or SYNR you should wait (with timeout) for LOCK==1. CRGFLG=0x1C before, and CRGFLG=0 after could mean that PLL didn't lock. Why? Either you didn't give it enough time, or your PLL filter doesn't work at all at 1MHz PLL clock.

 

I think i am not able to change PLLCLK. WHAT TO DO 


 

0 Kudos
Reply

965 Views
changebusclock
Contributor I

This is what i have done after receiving ur reply...

 

REFDV=0x07;

PLLCTL_CME=1;

PLLCTL_PLLON=1;

PLLCTL_AUTO=0; 

CRGFLG_LOCKIF=1;//clearing the lock 

while(CRGFLG_LOCK==0);//WAIT UNTIL LOCK==1

for(i=0;i<30000;i++)

 for(j=0;j<300;j++);

if((!CRGFLG_LOCKIF)&&CRGFLG_LOCK)

{

 CLKSEL_PLLSEL=1;

 while(1); 

}  

while(1)

{

 //code for LED blinking 

 

When i run the above code...

the processor waits for the LOCK flag to be set indefinitely....

 

KINdly help me in this regard.. i want the bus clock to be changed to 0.5MHz 

 

0 Kudos
Reply

965 Views
kef
Specialist I

So PLL doesn't lock at all. I think you should modify PLL filter components to suit 4MHz oscilator clock and 0.5MHz bus clock. S12X PLL filter calculator can be found here:

 

http://forums.freescale.com/freescale/board/message?board.id=16BITCOMM&thread.id=1780

 

 

Your code is almost OK, but LOCKIF should be cleared after LOCK sets to 1. So

 

REFDV=0x07;

PLLCTL_CME=1;

PLLCTL_PLLON=1;

PLLCTL_AUTO=0; 

while(CRGFLG_LOCK==0);//WAIT UNTIL LOCK==1

CRGFLG_LOCKIF=1;//clearing the lock 

for(i=0;i<30000;i++)

 for(j=0;j<300;j++);

if((!CRGFLG_LOCKIF)&&CRGFLG_LOCK)

{

 CLKSEL_PLLSEL=1;

 while(1); 

}  

while(1)

{

 //code for LED blinking 

0 Kudos
Reply

965 Views
changebusclock
Contributor I

Bear with me if i wasnt more specific with my requirement.

 

I want to transmit 0x33h from the microcontroller using SCI to an automobile for communication initiation. (communication is half duplex) Immediately after transmitting the  above said value,  SCI  baud rate has to be changed to  10.4kbaud 

 

Inorder to achieve the above said

Can i use an IO pin and a timer to transmit UART data 0x33h at 5 Baud (ie 1 start bit, 8 bits , 1 stop bit => 10 bits total ie 2000 milliseconds 1 bit has to be transmitted) start bit is low and stop bit is high in UART. 

Then on can i program SCI baud registers to 10.4 kbaud and continue the communication.

Will this work?

Am i correct ?

Can you through more light on the above said requirement. 

0 Kudos
Reply

965 Views
kef
Specialist I
Yes it will work, but that's another question and another thread
0 Kudos
Reply