SCI baud rate,  PLL ?

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

SCI baud rate,  PLL ?

ソリューションへジャンプ
1,513件の閲覧回数
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 ??

ラベル(1)
0 件の賞賛
1 解決策
692件の閲覧回数
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 件の賞賛
4 返答(返信)
692件の閲覧回数
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 件の賞賛
692件の閲覧回数
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 件の賞賛
693件の閲覧回数
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 件の賞賛
692件の閲覧回数
MO_84
Contributor III

 

Ok. that fixed the problem.

 

Thanks Kef and Sten for your help.

 

Its much appreciated.

 

Mo

0 件の賞賛