Question about crystals ( hardware)

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

Question about crystals ( hardware)

605 Views
GMVS
Contributor III

Hi

 

I'm trying to use a MC9S08DZ128MLL

but i still dont undestand the clock part

let's make this a hardware approach

 

the internal reference clock can only provide 25 kHz to 41.66 kHz


1) but i need a real time clock here, so  i need a 32kHz crystal attached... to both XTAL and EXTAL, right?

but what if i want a faster clock sometime?

 

2)lets say i'd want to work at 16MHz someday using the same hardware. is there a way to have both the 32kHz and the 16MHz crystals available to select? or would i have to remove one and place the other manually?

 

 

now, this is a software question

 

3) how do i make the micro work at 40MHz?

in hardware i understand i need to attach a square wave input clock en EXTAL, leaving XTAL free

what would be a good choice for the clk?

and how should i configure the micro to work with this?

 

 thanks 

Labels (1)
0 Kudos
Reply
3 Replies

348 Views
bigmac
Specialist III

Hello,

 

The choice of a 32.768 kHz crystal implies that you would utilize FEE mode as the operating mode for the MCG module.  With this arrangement, it is possible to achieve a bus frequency of up to 19.92 MHz, very close to the maximum allowable bus frequency.

 

If you wished to use a higher frequency crystal, it may be so as to use PEE mode, which has less jitter than FEE mode.  In this case the frequency must be divisible by a power of 2, down to a reference frequency range of 1 to 2 MHz.  Again the bus frequency will be a multiple of he reference frequency.

 

You would therefore establish a crystal frequency as part of the initial design process for a project.  I cannot see that there would be any need to change the reference frequency "on the fly".  There is already sufficient flexibility within the MCG module to reduce the bus frequency during the operation of the project.

 

Note that a 32kHz crystal will usually require different component values, compared to higher frequency crystals.

 

Regards,

Mac

 

0 Kudos
Reply

348 Views
GMVS
Contributor III

mmm...

 

what could be a good crystal option and clock configuration if i want to use a RTC but also an SPI, for example?

0 Kudos
Reply

348 Views
bigmac
Specialist III

Hello,

 

The 32.768 kHz crystal, assuming FEE mode for the MCG module, would be satisfactory for both the RTC and SPI modules.  For the RTC module the clock source selected would be MCGERCLK, which would apply the 32.768 kHz frequency to the input of the prescaler.  There are a number of different combinations for prescale and modulo settings, that can generate an interrupt at at precisely one second intervals.

 

The other requirement is for a relatively high bus frequency for suitable operation of the other peripherals.  With FEE mode, bus frequencies of either 16.777 MHz or 19.92 MHz would be available near the upper bus limit.  Reduced frequencies are also available by changing the BDIV setting within MCGC2 register.

 

The SPI clock rate is usually quite non-critical, providing it is below the upper limit for the slave device.

 

If a higher frequency crystal is desired, some possible choices would be 4.000 MHz or 4.9152 MHz.  These will provide maximum bus frequencies of 16 MHz and 19.66 MHz respectively.  Both frequencies would be suitable for the RTC module.  However, if you require SCI usage at relatively high standard baud rates (say 38400 baud), the low frequency crystal will produce more baud rate error than these high frequency crystals.  Actually, the 4.9152 MHz crystal will provide exact baud rate values.

 

Regards,

Mac

 

0 Kudos
Reply