SCI baud rate,  PLL ?

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

SCI baud rate,  PLL ?

Jump to solution
1,501 Views
MO_84
Contributor III

Hello again,

 

I'm able to send a receive the correct data using the below Initialization registers. My clock frequency is 4MHz and I'm using HCS12

void OpenSCI(void){    SCI0BDL=0x68; /* 4000000/16/2400==>2400 bps 4MHz is Bus clock for crystal freq of 8MHz*/               SCI0BDH=0x00; /* 0x00 ==>0x0068 is divisor to produce 2400 bps */    SCI0CR2=0x2C; /* enable SCI, enable receive interrupt */}

 

 

 

The problem starts when I change the clock from 4MHz to 24MHz using PLL code below and try to send data:

 

void Set_Clock(void){    CLKSEL &= 0x7F;    PLLCTL |= 0x40;    SYNR  = 0x05;    REFDV = 0x01;    while(!(0x08 & CRGFLG));    CLKSEL |= 0x80;} void OpenSCI(void){    SCI0BDL=0x71; /* 24000000/16/2400==>2400 bps 24MHz is Bus clock for crystal freq of 48MHz*/                 SCI0BDH=0x02; /* 0x00,0x0271 is divisor to produce 2400 bps */    SCI0CR2=0x2C; /* enable SCI, enable receive interrupt */}

 I can still send and receive data but its sending strange characters.

I think there's a problem with the baud rate. I have gone over the math and initialization and it looks correct.

 

Any ideas as to why I'm getting random characters ??

Labels (1)
0 Kudos
1 Solution
680 Views
Sten
Contributor IV

As kef says, the recommended way is to write SCIBD as a word, but if you want to write it as two bytes, you must write SCIBDH first and then SCIBDL, otherways the write of SCIBDH is ignored.

 

Sten

 

View solution in original post

0 Kudos
4 Replies
680 Views
kef
Specialist I

Why don't you write whole SCIBD register at once, SCIBD = 0x271.

 

From baud rate register bits description:

-Writing to SCIBDH has no effect without writing to SCIBDL, since writing to SCIBDH puts the data in a
temporary location until SCIBDL is written to.

 

Or, what you write to SCIBDH is ignored until you write to SCIBDL. Looking at you code it seems that SCI module sees SCIBD=0x71, which is about 13kbps at 24MHz bus. You may check that with scope.

0 Kudos
680 Views
MO_84
Contributor III

I'm still can't see where the problem is.

The code does what you say.

 

first it writes to SCIBDL and then to SCIBDH.

 

So I don't see how SCIBDH is engnored since it is written to after SCIBDL.

 

 

0 Kudos
681 Views
Sten
Contributor IV

As kef says, the recommended way is to write SCIBD as a word, but if you want to write it as two bytes, you must write SCIBDH first and then SCIBDL, otherways the write of SCIBDH is ignored.

 

Sten

 

0 Kudos
680 Views
MO_84
Contributor III

 

Ok. that fixed the problem.

 

Thanks Kef and Sten for your help.

 

Its much appreciated.

 

Mo

0 Kudos