HCS12 to transmit SCI at 115200 baud

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

HCS12 to transmit SCI at 115200 baud

5,151 次查看
Bernie
Contributor I
Hi everyone,
I am using an MC9S12A256B and would like to transmit on the serial line at 115200 bps. I am using a 6MHz crystal. From what I've read in a different forum, I will probably have to bump up my internal bus speed using the PLL to get this baud rate. Has anyone done this? Is there  a simple way to choose the PLL register values and the SCI divider values to get this baud? I was hoping to keep the bus clock as low as possible. I know I can bump it up to 48MHz and get the baud rate, but that draws a lot of current.
 
Thanks
Bernie
标签 (1)
0 项奖励
3 回复数

586 次查看
pittbull
Contributor III
hi,
you can use this:

#define BUSCLOCK "your_bus_clock_here"L
#define BAUDRATE(_x_) ((BUSCLOCK/16/(_x_))&0x1fff)
...
SCIxBD = BAUDRATE(115200L);
...

to set the baud rate depending on the bus clock
0 项奖励

586 次查看
imajeff
Contributor III
I have this in my GCC apps
 // PLL
 CLKSEL = 0;    // disable PLL to configure
 // xtal 16MHz, bus 24MHz
 SYNR  = 3 - 1;
 REFDV = 2 - 1;
 while (!(CRGFLG & 0x08))    // wait for PLL LOCK
 cop_optional_reset();
 CLKSEL |= 0x80;             // use PLL

It seems simple to calculate SYNR/REFDV:
oscclk * (SYNR+1) / (REFDV+1) will be bus frequency.
0 项奖励

586 次查看
Technoman64
Contributor III

Can you use Processor Expert and just create a test program and plug in the values you are using and/or needing and see what works and what does not work?

I just did a quick PE test using your device. With a 6mhz crystal you can use the PLL to get your required baud rate with 18mhz bus speed.

You can also use the Low and High speed features of Processor Expert and only increase the bus speed to 16mhz when you are going to use the SCI at 115200. When you are done with the transmission set it back to low speed to save on power.

Message Edited by Technoman64 on 05-18-200603:08 PM

0 项奖励