SH4 external clock

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

SH4 external clock

1,044 Views
gaminn
Contributor IV

Hello,

I buought 40 MHz external oscillator. How to enable this clock in MCU (SH4) - what to write to registers?

 

Thank you

 

Martin

Labels (1)
0 Kudos
7 Replies

444 Views
gaminn
Contributor IV

By the external oscillator I mean an external component which produces 40 MHz square wave. The oscillator is connected to EXTAL pin of my MCU.

0 Kudos

444 Views
bigmac
Specialist III

Hello Martin,

 

To use the 40MHz external oscillator module, you will need to select FBELP mode, as described in the data sheet.  However, for FBELP mode you will not be able to debug since the BDM will be disabled in this mode.  You will probably need to do your debugging using FEI mode.

 

What is your reason for choosing to use this particular oscillator module?  Using a 5MHz oscillator or crystal would make it feasible to use FEE mode, and still achieve the maximum bus frequency.

 

Regards,

Mac

0 Kudos

444 Views
gaminn
Contributor IV

Thank you for your reply. I tried to run this code at the beggining of my program:

 

ICSC1 = 0b10000000; // CLKS = 0b10
ICSC2 = 0b00001000; // LP = 1

 

but with no success.

 

Is it the code that should enable FBELP mode? What should be the level of my external oscillator output?  Must it be 0 - Vcc or can it be less?

 

I need precise clock for my application. I think I can't achieve 50 ppm over 0-70°C by using crystal + internal MCUs oscillator and PLL. Or can I?

0 Kudos

444 Views
bigmac
Specialist III

Hello Martin,

 

Perhaps the RANGE bit, within ICSC2, should be set for high frequency operation, even though you are using an external oscillator module.  The output from the module will need to be a square wave with full logic swing at 5 volts, particularly at the frequency you are using.

 

For a much lower oscillator frequency of, say 5 MHz, a lower swing may be tolerated by configuring as an external crystal, complete with bias resistor between the two oscillator pins at the MCU, and then AC coupling the oscillator module output into EXTAL.

 

When you fail to enter FBELP mode, does operation continue in the default FEI mode?  Another factor might be that, if the BDM is active when you attempt to switch for FBELP mode, this may prevent the switching from occuring.  I am not sure about this.

 

Using a suitable crystal, achieving 50ppm stability over 0-70 degree C may be achievable, but would be difficult with the Pierce oscillator configuration used, due to temperature variation of the load capacitance.  Even if the external capacitors are NPO type, the pin capacitance will appear in parallel with each capacitor, and will be a significant component when a low capacitance crystal is used.  You would also need to provide frequency trimming of the reference.

 

However, an oscillator module of 5MHz maximum frequency might be utilised.  When using FEE mode, the bus frequency would be subject to short term jitter, a characteristic of the FLL circuit, but this will not affect the long term frequency accuracy.  The jitter can be avoided within the timing modules, by choosing a clock source other than the bus frequency.

 

The RTC module may alternatively be driven by ICSERCLK, directly from your external oscillator.  The TPM and MTIM modules may alternatively be driven by one half the ICSFFCLK frequency.  For a 4MHz oscillator this would be 15.626 kHz, and for a 5MHz oscillator, 19.53125 kHz.

 

Regards,

Mac

 

 

 

 

0 Kudos

444 Views
gaminn
Contributor IV

Hello bigmac,

I have probably suceeded in enabling external 40 MHz clock. See this code:

 

 

void main(void) {  volatile unsigned char i = 0;    ICSC1 = 0b10000000;  ICSC2 = 0b00101010;  PTADD_PTADD0 = 1
   for(;;) {    PTAD_PTAD0 = 1;    PTAD_PTAD0 = 0;    i = ICSSC;    __RESET_WATCHDOG();  }

 

 

I connected oscilloscope to the PTA0 pin. I can see square wave, its high level (that is time between PTAD_PTAD0 = 1; and PTAD_PTAD0 = 0:smileywink: lasts for 250 ns, that is 4 MHz. Considering that BCLR instruction needs 5 cycles (bus cycles?), I get 20 MHz of bus clock and 40 MHz (2 * 20) of system clock.

 

But I'm little confused - I can debug (run, stop, step, set breakpoint) my MCU..  I use Codewarrior 5.9.0 and USBDM 4.0 (USBDM-CF). How is it possible?

 

Martin

 

 

 

0 Kudos

444 Views
bigmac
Specialist III

Hello Martin,

 

Maybe it is possible that the MCU mode does not switch because BDM is already active, and remains running in FEI mode, with a bus frequency of approximately 20 MHz.  Reading the ICSSC register should reveal whether this is the case.

 

Regards,

Mac

 

0 Kudos

444 Views
gaminn
Contributor IV

Hello bigmac,

 

sorry, I forgot to mention that I can see that ICSSC holds 0x08 value during debugging. It means, that the MCU runs from external clock...

 

Martin

0 Kudos