External Crystal for MC9S08JM32

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

External Crystal for MC9S08JM32

Jump to solution
2,639 Views
Betadine
Contributor III

Hi,

 

I´m moving a project with MC9S08JM32 using internal oscillator for another one with the same MCU with external oscillator because I want to speed up baud rates in RS232 (with internal osc I work with 9600 without problem).

 

Problem is I´ve never implemented such simple thing and I have see some of the discussions here but most of the links are broken (inside freescale forums)...

So if anyone can point me to some place or AppNote on how to build it?

I´m not very sure which frecuency to choose for the crystal... also I´m not sure how is the schematic of it, etc... (means I don´t know nothing)

 

I will use the RS232 through a FT232 USB/serial converter

And also the SPI for a Dual DAC from MICROCHIP MCP4922 (in the begining I was going to use I2C but seems to be more complicated and is worst for power saving)

 

Thanks for any tip/link/appnote!

 

Cheers

 

Cristian.

Labels (1)
0 Kudos
Reply
1 Solution
2,021 Views
bigmac
Specialist III

Hello Cristian,

The capacitive load for the crystal consists effectively of each capacitor, plus additional pin and stray capacitance, connected in series. For equal value capacitors C,

(C + Cpin) / 2 = Cload.

C + 10 = 2 * 18 pf

C = 26 pf, say preferred value 27 pF

When the capacitive loading differs from the specified value used for calibrating the crystal frequency, there will be a small frequency shift, probably less than a kHz or two.  For most MCU applications, this is usually non-critical.

The series resistance Rs will limit the power dissipation within the crystal - usually applicable to low frequency crystals.  For higher frequency crystals, the resistor is commonly omitted without any problems.  Too high a value for Rs can prevent reliable oscillation.

Regards,

Mac

View solution in original post

0 Kudos
Reply
10 Replies
2,021 Views
Betadine
Contributor III

I almost have it I think...

Rf = 5Megaohms

C1 = C2 = 16pF

for C1 and C2 I´ve used the following formula

Load Capacitance of X1 = 18pF -> [C*C/C+C] + 10pF = 18pF -> C=16pF aprox

I´ve not considered Cin and Cout... so I guess C will be a bit more of 16pF but it will more or less around those values...

Question is... How I calculate the Value of Rs???

Each place on internet say something different... some of them says that due to the high Q value of quartz crystals Rs could be 0ohms... but other places speak about a few ohms...

Any idea?

0 Kudos
Reply
2,022 Views
bigmac
Specialist III

Hello Cristian,

The capacitive load for the crystal consists effectively of each capacitor, plus additional pin and stray capacitance, connected in series. For equal value capacitors C,

(C + Cpin) / 2 = Cload.

C + 10 = 2 * 18 pf

C = 26 pf, say preferred value 27 pF

When the capacitive loading differs from the specified value used for calibrating the crystal frequency, there will be a small frequency shift, probably less than a kHz or two.  For most MCU applications, this is usually non-critical.

The series resistance Rs will limit the power dissipation within the crystal - usually applicable to low frequency crystals.  For higher frequency crystals, the resistor is commonly omitted without any problems.  Too high a value for Rs can prevent reliable oscillation.

Regards,

Mac

0 Kudos
Reply
2,021 Views
Betadine
Contributor III

That makes more sense (adding Cpin to each capacitance in the formula)

Now it´s very clear. Thanks for the correction.

About Rs, is there any table or something for reference? I don´t know if 4MHz is (high or low frecuency). I suppose that f<1MHz is low frecuency, but I´m not sure where is the threshold.

I was going to use 100 ohms because intuition. Are there any table with recommended values?

Best Regards,

Cristian.

0 Kudos
Reply
2,021 Views
Betadine
Contributor III

I´ve discovered the AN3208 Crystal Oscillator Troubleshooting Guide from freescale.

Hope it serves for anyone... I will try to get the answers from there.

0 Kudos
Reply
2,021 Views
Betadine
Contributor III

Hi,

Considering that the UART is the element which limits the minimum clock frecuency... (because the SPI frecuency needed is much lower for my application)

We have from the datasheet:

uart.jpg

So considering a max baud rate of 115200...

With a 4Mhz crystal... the max baudrate will be 4Mhz/16 = 250000

Is this correct? 4Mhz crystal could be the right choice... I´m thinking about this one:

9C-4.000MAAJ-T - TXC - XTAL, 4.000MHZ, 18PF, SMD, HC | Farnell España

So for the schematic, from the datasheet we have:

aa.JPG.jpg

And then, the datasheet says:

  1. RF is used to provide a bias path to keep the EXTAL input in its linear range during crystal startup; its value is not generally critical. Typical systems use 1 MΩto 10 MΩ. Higher values are sensitive to humidity and lower values reduce gain and (in extreme cases) could prevent startup.
  2. C1 and C2 are typically in the 5-pF to 25-pF range and are chosen to match the requirements of a specific crystal or resonator. Be sure to take into account printed circuit board (PCB) capacitance and MCU pin capacitance when selecting C1 and C2.
  3. The crystal manufacturer typically specifies a load capacitance which is the series combination of C1 and C2 (which are usually the same size). As a first-order approximation, use 10 pF as an estimate of combined pin and PCB capacitance for each oscillator pin (EXTAL and XTAL).

I would put Rf = 5MΩ  (for example)

The Load capacitance of the crystal (looking the datasheet) says 18pF... I´m not sure what values should I use for C1 and C2...

Values for Rs are not mentioned... in the s08jm datasheet... :s

How is it look?

0 Kudos
Reply
2,019 Views
bigmac
Specialist III

Hello Cristian,

To provide an exact baud rate of 115200, the bus frequency would need to be a multiple of 1.8432 MHz.  Assuming the use of either FEI or FEE modes for generating the bus clock, the bus frequency would need to be 9.216, 16.589 or 18.432 MHz.  The POR default mode is FEI.

For FEI mode, the bus frequencies 9.216 and 18.432 MHz would require a trimmed internal reference frequency of 36.0 kHz.  For 16.589 MHz, the internal reference frequency would be 32.4 kHz.  Either of these reference frequencies would need to be specifically calibrated with a suitable trim value.  For FEE mode, the crystal frequency would need to be a power-of-2 multiple of these reference frequencies, but not exceed 5 MHz.  For example, a 36.0 kHz reference would require a crystal frequency of 2.304 or 4.608 MHz.  Such frequencies may not be readily available.

However, other crystal frequencies may be able to achieve sufficient accuracy for SPI operation.

Your original choice of 4.0 MHz would be problematic, i.e.  4.0 MHz would divide down to a reference frequency 31.25 kHz (the minimum allowable value).  This is then multiplied by a factor of 512 for a bus frequency of 16.0 MHz (assuming BDIV factor of 1).  The closest baud divisor value would be 9, which would give a baud error of -3.55 percent, very close to the usual error limit.  For reliable operation, I would usually aim for an error less than 1 - 2 percent.

A crystal frequency of 4.1943 MHz (which used to be readily available ) would give a baud error of +1.14 percent.

Regards,

Mac

2,019 Views
Betadine
Contributor III

Ok!!

I´m getting with it (more or less)

Just preparing some tutorials for calculating these things. I have made the calculations for a baud rate of 57600 and the error with the 4.1943 Mhz crystal is the same!! around 1.1%

So I can play with differents SCI baud rates and the error will be the same! Marvellous! I´m going to choose that crystal for sure it seems that frecuency it´s made for SCI applications jeje.

I will try to post the tutorial for calculating these things.

thank you very much!

0 Kudos
Reply
2,019 Views
Betadine
Contributor III

Thanks bigmac,

There is a lot of info here to investigate... I will use SCI and SPI, but never used SPI...

The SPI is not critical in velocity (6 updates each second more or less)

The SCI, I would like to use upper baudrates than 9600 ...for example 38400 - 57600 -115200

EDIT: I´m wondering if 4MHz is too much frecuency for my application...¿?

I´m going to read carefully the datasheet to see how affects the crystal frecuency in both modules. I wasn´t aware of these operations.

0 Kudos
Reply
2,021 Views
weapon
Senior Contributor I

Hi Cristian,

If you intend to use USB module of JM32, the bus clock must be 24MHz in PEE mode, as a result, the crystal can be 1M, 2M,4,8M,12M,16M...

there is not difference in using those crytals, you can choose any one of them. Our demo board uses 12MHz, you can choose 12M too, so that some demo code can run on your board without modifing MCG configuration.

B.R

XWP 

2,021 Views
Betadine
Contributor III

Hi Weiping Xu,

Thanks for your answer, I will not use the USB module... just a USB/serial converter (FT232) so the MCU will use only the serial interface, and the SPI for the DACS of course.

I just want to rise a bit the baud rate from the serial interface, but no idea about the proper frecuency of the crystal vs power saving (is a li-ion battery powered system)

EDIT:

I´ve just look into page 29 of the datasheet (Basic system connections) and I see the schematic, in page 30 some values are recommended...

I will keep investigating, I appreciate any tip

Cheers

0 Kudos
Reply