ICG With External Oscilattor

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

ICG With External Oscilattor

跳至解决方案
901 次查看
davidboyd
Contributor I

Hi,

I'm using an 9S08AC128 with an external 4.000MHz canned oscillator, and require a bus clock of 16.000MHz.  I've assumed I will need to switch to FEE mode, with N=16 and R=2.

 

To test my overall project I have a 32.000MHz oscillator attached, creating a 16.000MHz bus clock.

ICG_Init               mov #%01010000,rICGC1

                            mov #%00000000,rICGC2

                            rts

The above code works fine.  I have a timer generating a 1Hz signal that flashes a LED and it's quite accurate as you would expect. Now it's time to swap over to the 4.000MHz oscillator.

 

Page 201 of the Reference Manual provides an example that generates a bus clock of 20 MHz from a 4MHz crystal. The code example is:

ICG_Init     mov #%01111000,rICGC1

                            mov #%00110000,rICGC2 ;N=10, R=1

                            rts

 

When I run this code I get a bus clock substantially below 20 MHz (visible by a very slow flashing LED). My plan was to then change ICGC2 to N=16 and R=2 to generate my 16.000MHz bus clock.

 

Curiously page 202 of the same Reference Manual gives a different value for ICGC1 than the previous page for the same example, and I suspect that's a typo.

 

Any suggestions about what I have overlooked? 

 

David


标签 (1)
标记 (3)
0 项奖励
回复
1 解答
768 次查看
bigmac
Specialist III

Hello David,

Using a 4MHz external oscillator, the combination N = 10, R = 1 should correctly generate a 40 MHz DCO frequency, and a 20 MHz bus frequency.  This is on the upper DCO frequency limit.  It might pay to initially leave R at the default value of 2 whilst setting up FEE mode.  After lock has occurred, you would then set R = 1 as a separate process.  This will avoid the possibility of overclocking the MCU prior to lock occurring.

For a bus frequency of 16 MHz, the only combination that will work is N = 8, R = 1.  If you attempt to set N = 16, this will exceed the maximum DCO frequency limit, and lock will not occur.

Since you are using an external oscillator, rather than a crystal, it is unnecessary to set bit-5 of ICGC1.  This will free up the XTAL pin for GPIO use.

Regards,

Mac

在原帖中查看解决方案

0 项奖励
回复
4 回复数
769 次查看
bigmac
Specialist III

Hello David,

Using a 4MHz external oscillator, the combination N = 10, R = 1 should correctly generate a 40 MHz DCO frequency, and a 20 MHz bus frequency.  This is on the upper DCO frequency limit.  It might pay to initially leave R at the default value of 2 whilst setting up FEE mode.  After lock has occurred, you would then set R = 1 as a separate process.  This will avoid the possibility of overclocking the MCU prior to lock occurring.

For a bus frequency of 16 MHz, the only combination that will work is N = 8, R = 1.  If you attempt to set N = 16, this will exceed the maximum DCO frequency limit, and lock will not occur.

Since you are using an external oscillator, rather than a crystal, it is unnecessary to set bit-5 of ICGC1.  This will free up the XTAL pin for GPIO use.

Regards,

Mac

0 项奖励
回复
768 次查看
davidboyd
Contributor I

Thanks for the reply Mac.

Therefore are you suggesting the following for a 4MHz external oscillator generating a bus clock of 16MHz:

ICG_Init               mov #%01011000,rICGC1      ;RANGE=hi, CLKS=11(FLL engaged, external)

                            mov #%00100001,rICGC2      ;N=8, R=2

icg_wait_lock       brclr 3,rICGS1,icg_wait_lock   ;wait for the FLL to lock

                            mov #%00100000,rICGC2      ;N=8, R=1

                            rts

David

0 项奖励
回复
768 次查看
bigmac
Specialist III

Hello David,

Yes, this is what I had suggested.  Does it work?

Regards,

Mac


0 项奖励
回复
768 次查看
davidboyd
Contributor I

Hi Mac,

Yes, that worked perfectly.  The wait for lock was essential.

Thanks for your help.

David

0 项奖励
回复