SH8 or QG8 CLOCK - FEE vs. FBE vs. FBELP

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

SH8 or QG8 CLOCK - FEE vs. FBE vs. FBELP

1,449 Views
z537z
Contributor I

I've got an application that needs a reasonably fast, and very stable clock to measure the frequency of an incoming square wave up to a few kHz.

I'm not getting a stable reading using the internal clock, so I dug up a couple of crystals: a 2MHZ and a 16MHz crystal and now I'm wondering how to make this work? Can I use the 16M?

The two ICS control registers are very confusing, can anybody explain any of this for me?

In particular: What does the High Gain option do? Do I need high or low frequency range?


It sounds like using anything but FBELP limits my external source to around 4.6MHz to keep a 36kHz FLL...

 

Any help is appreciated, thanks!

Labels (1)
0 Kudos
6 Replies

647 Views
bigmac
Specialist III

Hello,

 

For the 'SH8 device, the maximum crystal frequency allowed is 5 MHz for FEE and FBE modes, and 16 MHz for FBELP mode.  The reason that FBE mode has a lesser value is that the FLL still requires to run in this mode, and this supplies the BDC clock for debug purposes.  For FBELP mode, the FLL does not run, so there is no BDC clock.available.

 

For period measurement of an external signal, using input capture for the TPM module, there is a further issue that the bus clock will be subject to the normal FLL jitter when using FEE mode, and this may result in some uncertainty of the measurement when the TPM clock is supplied from the bus.  An alternative ICSFFCLK may be selected for the TPM module source, but this appears to be the divided down to 32 kHz external reference.  Some other devices are more flexible in that the non-divided external reference may be used for the TPM clock.

 

It would therefore appear that you have the choice of FBE mode with a maximum bus frequency of 2.5 MHz, or FBELP mode with a maxumum bus frequency of 8 MHz, but no debug capability.

 

Regards,

Mac

 

0 Kudos

647 Views
z537z
Contributor I

Thanks Mac, but I'm still a little confused as to the whole operation of this thing:

 

1. I tried just running a simple program using the internal clock,

CLKS = 01

IREFS = 1

BDIV = 00

And toggling an output port every 50 cycles.

It comes out as a crazy low frequency (like 6Hz).

Change CLKS to 00 and my output is in the 3-3.5kHz area, but that still doesn't make any sense to me.

 

2. Using the same program, I can't get the 2MHz crystal to work at all, the output stays the same when I pull the chip out, put it back in, reset, etc.

 

I've read your post https://community.freescale.com/message/58177#58177regarding maximum usable bus frequency, and I think I can get by with a 2-4MHz bus clock, but currently I seem to be a few orders of magnitude lower than that.

 

 

Clock jitter is the primary issue here, I just want a stable source to work with.

 

How would I set up my registers for either of these options?

I'm done debugging and don't need the BDM at this point...

 

Thanks again

 

0 Kudos

647 Views
bigmac
Specialist III

Hello,

 


z537z wrote:

 

1. I tried just running a simple program using the internal clock,

CLKS = 01

IREFS = 1

BDIV = 00

And toggling an output port every 50 cycles.

It comes out as a crazy low frequency (like 6Hz).

Change CLKS to 00 and my output is in the 3-3.5kHz area, but that still doesn't make any sense to me.


By setting CLKS to 01, you are deriving the bus clock directly from the internal reference (FBI mode), i.e. a bus frequency of nominally 16 kHz.  Not what you require.

 

With a setting of 00, the bus clock is sourced from the FLL (FEI or FEE mode).  The setting IREFS = 1 gives FEI mode.  To use the setting BDIV = 00, the internal reference must have previously been trimmed, otherwise it is possible to exceed the maximum allowable bus frequency because of the wide initial tolerance for the internal reference..

 

To directly source the external reference for FBE or FBELP mode, the CLKS setting should be 10.

 


z537z wrote:

 

2. Using the same program, I can't get the 2MHz crystal to work at all, the output stays the same when I pull the chip out, put it back in, reset, etc.

 


A possible reason here is that you may not be enabling for external crystal use, requiring use of two pins.  The alternative is for an external clock source input, requiring only a single pin.  For crystal usage, EREFS = 1.   If the external reference does not oscillate, the use of the reset default FEI mode will continue.

 

The other relevant settings within ICSC2 register that might be used:

RANGE = 1 for crystals in MHz range

HGO = 1 will ensure oscillation for crystals in MHz range

LP = 0 for FBE mode, or LP = 1 for FBELP mode

 

All bits for the ICSC2 register should be written simultaneously, since some bits are write once for some MCU types.  A 2 MHz crystal, for FBE mode, will give a bus frequency of 1 MHz.  You will need a 4 MHz crystal to achieve a 2 MHz bus.

 

Regards,

Mac

0 Kudos

647 Views
z537z
Contributor I

Mac - this all makes sense, and I'm thinking my reused crystal is shot (yes, I have the caps to ground on either side), thus the chip keeps defaulting to the internal ref.

SO going forward, here's my test program:

 

 

void main(void) {       //ICS setup  ICSC1 = 0b10111000; //Ext source, RDIV = 128 for 4.6MHz crystal, IREFS = 0  ICSC2 = 0b00110100; //BDIV = 1, Hi Range, Hi Gain, Oscillator requested       //PORT A setup  PTADD_PTADD3 = 1;     //output to toggle      for(;;) {    asm BSET 3, 0x00;  asm BCLR 3, 0x00;  } //for }//main\

 

Thanks for the clarification on the register defs -  Nothing seems to fully describe the gain, range, etc. in the manual.

I'll be picking a 4 or 4.6MHz crystal and this will allow for a 2 or 2.3MHz busclk. Which should be plenty to accurately measure a max 3kHz incoming signal for my final application.

 

Thanks again

0 Kudos

647 Views
bigmac
Specialist III

Hello,


z537z wrote:

Mac - this all makes sense, and I'm thinking my reused crystal is shot (yes, I have the caps to ground on either side), thus the chip keeps defaulting to the internal ref.


More importantly, do you also have a high value resistor (1Mohm to 4.7Mohm) between the two pins, to provide biassing for the oscillator?  The oscillator will not work without this component.

 

Regards,

Mac

 

0 Kudos

647 Views
z537z
Contributor I

Well THAT would certainly help.

Thanks for the duuuuhhhhhhhhhhh support :smileytongue:

 

Got it all working finally, thanks again for the assistance.

 

0 Kudos