QG8 SCI 115200 Baudrate

cancel
Showing results for 
Search instead for 
Did you mean: 

QG8 SCI 115200 Baudrate

Jump to solution
476 Views
LiveMike
Contributor II

searched for 2 hours, read a dozen threads, i just need a simple answer.

i read the ICS needs to be 36KHz for the BUSCLK to be 9.216MHz and the SCI baud should be 5 for the baudrate to be 115200.

 

the SCI baud part is easy enough:  SCIBDH = 0x00 and SCIBDL = 0x05

 

what to i set ICSC1, ICSC2 (if anything), ICSTRM, and ICSSC(if anything) - to get the BUSCLK to be 9.216MHz?????????????????????

 

-------

i assume this:

ICSC1 - CLKS =00, RDIV = x (this is the number i think i need to figure out), IREFS=1(default) and IRCLKEN IREFSTEN both = 0.

 

i prob jus set ICSC2 to 0x00 or 0x40(default) or do i need to mess with BDIV?

 

and i know ICSTRM is default 0x80, do i need to change this too?

 

I REALLY ONLY NEED TO KNOW WHAT TO SET THESE REGISTERS TO--

but...

a formula would be nice to.  i guess i dont understand this clock frequency at all.

i'm pretty sure i'm starting with 31.25 MHz.  how does changing RDIV, BDIV and ICSTRM (MATHEMATICALLY SPEAKING) change/adjust that?!?!?!?!?

 

thanks in advance for providing the REGISTER VALUES to accomplish 115200 baud, and thanks for any formula/explanation.

 

and HAPPY FRIDAY!!!

 

-mike

Labels (1)
0 Kudos
1 Solution
88 Views
bigmac
Specialist III

Hello Mike,

You seem to have a problem with your trim settings.  Here is what I think they should be -

ICSTRM = NVICSTRM;           // 8-bit trim value

ICSSC_FTRIM = NVFTRIM_FTRIM; // Single bit fine trim

Regards,

Mac

View solution in original post

0 Kudos
3 Replies
88 Views
bigmac
Specialist III

Hello Mike,

For FEI mode of the ICS module within the MC9S08QG8 device the trimmed reference frequency must lie between 31.25kHz to 39.0625kHz, to give a DCO frequency range 16 - 20 MHz (512 times the reference).  This is the lock range for the FLL.  The maximum bus frequency will be one half the DCO frequency, with a BDIV setting that provides frequency division by 1.

Since FEI mode is the power-on default, your code can write the default values to the registers, with a couple of exceptions.  The BDIV setting will need to change from the default, but this should occur only after the reference trim process has taken place, otherwise you could potentially exceed the maximum allowable bus frequency.  Secondly, your reference trim calibration process will need to be for a reference frequency of 36.0 kHz, rather than the usual factory value of 31.25 kHz.  This is done when programming of the device takes place.

The trim calibration process will program the trim setting into a specific flash memory location (NVTRIM).  Your code must read this value from flash memory, and write to the actual trim register.

For the high baud rate used, the SCI receive ISR processing needs to be completed in somewhat less than 800 cycles, otherwise received data may be lost.  Other interrupts may need to be disabled during this process.

It may be better to choose a device type that has a maximum bus frequency of 20 MHz, rather than 10 MHz.  There would be a wider choice of bus frequencies, and for the higher bus frequency there would be more cycles available to complete the SCI receive ISR.  A trimmed bus freqiency of 18.4320 MHz would increase the limit to 1600 cycles.

Regards,

Mac


0 Kudos
88 Views
LiveMike
Contributor II

when the PEMICRO connection manager window pops up, i check the box "Use custom trim reference frequency", and set the value to 36000.00 Hz.

then i put this code in _Startup:

ICSTRM = NV_FTRIM;

  ICSC1 = 0x04;

  ICSC2 = 0x00;

  SCIBDH = 0x00;

  SCIBDL = 0x05;

does this give me a baudrate of 115200 ???

thanks,

-mike

0 Kudos
89 Views
bigmac
Specialist III

Hello Mike,

You seem to have a problem with your trim settings.  Here is what I think they should be -

ICSTRM = NVICSTRM;           // 8-bit trim value

ICSSC_FTRIM = NVFTRIM_FTRIM; // Single bit fine trim

Regards,

Mac

View solution in original post

0 Kudos