How to determine the HCS12 flash FCLKDIV setting

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

How to determine the HCS12 flash FCLKDIV setting

2,844 Views
AndersJ
Contributor IV
Various application notes decribe how to set FCLKDIV, based on
"oscillator frequency", "bus clock", "oscillator" etc etc.
 
Which frequency is it?
* Crystal frequency
* Bus frequency
* PLL frequency
* etc
 
With a 16MHz crystal and no PLL, how should FCLKDIV be programmed?
 
Thanks,
Anders J
 
Labels (1)
0 Kudos
3 Replies

497 Views
Lundin
Senior Contributor IV
Crystal frequency = the number printed on the crystal.

Oscillator frequency = crystal frequency, unless you are using an external oscillator.

PLL frequency = if the PLL is used, it is the same as the oscillator frequency multiplied/divided by a number.

Bus frequency = either the oscillator frequency / 2 (default), or the PLL frequency.


FCLKDIV is calculated based on both bus frequency and oscillator, as you can see in the algorithm described in the manual. You need to set it to a value between 150-200kHz. Also note that FCLKDIV is a write-once register, so you need to write everything at once, not bit-by-bit.

Can't give you a register value for 16MHz, but you will probably want to make a generic algorithm working with any frequency anyway.
0 Kudos

497 Views
Nabla69
Contributor V
Hello,
 
I agree with all but a small thing I want to flag up.
Even the PLL clock is divided by 2 before feeding th bus.
Please see enclosed picture from S12DG128 CRG datasheet.
 
Alvin.
0 Kudos

497 Views
Lundin
Senior Contributor IV
Yes, you are correct. PLL clock replaces the oscillator clock and in either case it is divided by 2 to get the bus clock.
0 Kudos