How to determine the HCS12 flash FCLKDIV setting

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

How to determine the HCS12 flash FCLKDIV setting

3,168 次查看
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
 
标签 (1)
0 项奖励
回复
3 回复数

821 次查看
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 项奖励
回复

821 次查看
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 项奖励
回复

821 次查看
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 项奖励
回复