Trying to set baud rate on HCS micro

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

Trying to set baud rate on HCS micro

Jump to solution
2,200 Views
dweight
Contributor I

Hi,

 

I'm trying to communicate with a serial LCD hooked up to a microcontroller (HCS08), the display uses a 115k baud rate. I'm using a 9.8MHzexternal xtal, and with the baud rate divisor set at 5 this gives em a 7% mismatch in baud rate. Can I get this closer?

 

Thanks in advance for your help,

Labels (1)
0 Kudos
1 Solution
689 Views
tonyp
Senior Contributor II

It'd be nice to know which MCU you're dealing with.

 

I think xtal is irrelevant.  You (and we) need to know the bus clock (BUSCLK), which is a function of several things, like use of FLL, BDIV, etc.

 

Once you know the bus clock, divide that by 16 and the baud rate you want, and use that value.

 

For example, for bus of 28MHz (a nice 4MHz-xtal based bus clock for QE128), to get the baud rate 115200, you'd use: 28E6/(16*115200)=15.19~15 (actual baud 116666.66, only 1.27% off) if I got all the math right.

Message Edited by tonyp on 2009-07-30 05:45 PM

View solution in original post

0 Kudos
6 Replies
689 Views
sakthivelkuland
Contributor III

Hi All,

Thanks for the information . i need to have some more information about 115200 baud rate setting,

For my application i have using 4MHZ external crystal, what is the bus clock is needed to use the 115200 BR for my UART Communication.?

Please can any one help me to configure bus clock correctly?

My program MCU configuration RDIV = 2, CLKS = 0, BDIV = 1, PLLS =1, VDIV= 0111 (Multiply by 28.) to for getting 28MHz bus clock. how i can check my bus clock?

0 Kudos
690 Views
tonyp
Senior Contributor II

It'd be nice to know which MCU you're dealing with.

 

I think xtal is irrelevant.  You (and we) need to know the bus clock (BUSCLK), which is a function of several things, like use of FLL, BDIV, etc.

 

Once you know the bus clock, divide that by 16 and the baud rate you want, and use that value.

 

For example, for bus of 28MHz (a nice 4MHz-xtal based bus clock for QE128), to get the baud rate 115200, you'd use: 28E6/(16*115200)=15.19~15 (actual baud 116666.66, only 1.27% off) if I got all the math right.

Message Edited by tonyp on 2009-07-30 05:45 PM
0 Kudos
689 Views
dweight
Contributor I

Thanks for your help, the mcu is a MC9S08DZ60. Unfortunately the bus division is set due to the need to generate an interrupt every millisecond, so it looks like I'm stuck with a 7% error unless the xtal can be changed to a faster one,

Thanks

0 Kudos
689 Views
bigmac
Specialist III

Hello,

 

A 7 percent baud rate error will likely give unsatisfactory results.

 

By choosing a crystal frequency above 5 MHz you have ruled out using the FLL. However, it would appear still feasible to use the PLL (PEE mode).

 

RDIV = 8 will give a PLL reference frequency of 1.2288 MHz. Using VDIV = 12, and BDIV = 1 should give a bus frequency of 7.3728 MHz. This should provide an exact baud rate of 115200 with a baud divisor setting of 4.

 

How accurate does the 1 ms tick need to be? For an exact period based on an integral number of bus cycles, the bus frequency (in Hz) would need to be evenly divisible by 1000. With a 9.8304 MHz crystal, this will never be exactly met whatever method is used to generate the bus clock.

 

Regards,

Mac

 

Message Edited by bigmac on 2009-07-31 04:47 AM
0 Kudos
689 Views
tonyp
Senior Contributor II
Just as a note: Although I haven't used that specific MCU variant to know all the clock options and divisors it has, a one-millisecond interrupt is usually possible in more than one ways, so you normally shouldn't have to be stuck to just one bus clock.
0 Kudos
689 Views
bigmac
Specialist III

Hello,

 

An alternative way of expressing your requirement is to say that the bus clock frequency requires to be an integer multiple of 1.8432 MHz.  For some devices, it is possible that a 9.8304 MHz crystal may not be able to achieve this bus frequency with sufficient accuracy.

 

Regards,

Mac 

0 Kudos