Skip to main content
RWeil.2
Associate III
December 2, 2023
Question

External clock instead of oscillator

  • December 2, 2023
  • 4 replies
  • 6026 views

Hi,

currently, I am using an NX2016SA (as recommended by ST) to generate the HSE (32 MHz) for an STM32WB55RGV6 microcontroller.

I did not calibrate it, but so far everything works and I have a BLE range of up to 25 meters.

Now I am planning to getting my device certified for BLE, but I worry, because I did not calibrate the HSE. I don´t think I have equipment available to calibrate a signal to +- 25 ppm. Sounds a bit insane to me.

I did some measurements first: I switch between HSI and HSE and measure a current consumption of 3,36 mA for the HSE crystal at 3 V (1,13 mA / V is specified in the datasheet). I get a startup time of just 120 us from HSI to HSE. In the datasheet, a typical time for the XOREADY signal is specified as 250 us. How can it be that fast?

To switch between HSE and HSI, I use the following code:

 

void Turn_On_HSI(void)
{
 LL_RCC_HSI_Enable();
 while(!LL_RCC_HSI_IsReady())
 {
 }
 LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI);
 while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI)
 {
 }
 SystemCoreClockUpdate();
 LL_RCC_HSE_Disable();
 return;
}

void Turn_On_HSE(void)
{
	LL_RCC_HSE_Enable( );
	__HAL_FLASH_SET_LATENCY(FLASH_LATENCY_1);
	while(!LL_RCC_HSE_IsReady( ))
	{
	}
	LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSE);
	while (LL_RCC_GetSysClkSource( ) != LL_RCC_SYS_CLKSOURCE_STATUS_HSE)
		{
		}
	SystemCoreClockUpdate();
	LL_RCC_HSI_Disable();
}​

 

Now, in order to avoid the manual calibration, I am thinking about switching to an external clock, with its own oscillation circuit (e.g. SiT1533). There are external clocks available for 32 Mhz with a current consumption of approx. 3 mA. BUT: I have not found a single external clock, that has a startup time of less than 1 ms (max.). Why? Does anybody else use an external clock or does everyone use external oscillators? Especially in regard to BLE advertising, I see it as problematic, that the clock would have a startup time of 1 ms. This would drive up the current consumption by a lot.

Another question: In the reference manual RM0434, it is specified, that an external clock has to have a sinus signal. I haven´t found many external clocks with a sinus. 99 % of them have a rectangle. If I use the MCO (master clock output) to output the clock of the external crystal, I also see a rectangle in the oscilloscope.

So, to sum up my questions:

  • Does the MCO show the exact waveform of the input signal? Or to be more precise, does the NX2016SA generate a sinus signal?
  • Is it true, that an external clock for the HSE would have to be a sinus signal? That would limit the available products to ~1 %.
  • Is it generally recommended to use an external clock instead of the oscillator or are the downsides so bad, that nobody does it?
  • I did not order an external clock yet and thus, could not test it. Is the typical specified startup time generally much less than the max. specified startup time? If it really is 1 ms for most external clocks, I see that as a total deal breaker.

Kind regards

4 replies

RWeil.2
RWeil.2Author
Associate III
December 4, 2023

Sorry, I think you misunderstood my question. I am not asking how to calibrate the HSE. I know how to calibrate it, but I am looking for a way, how I could avoid buying expensive measurement equipment to do so.

Thus, my questions, of which none have been answered.

AScha.3
Super User
December 4, 2023

>Does the MCO show the exact waveform of the input signal?

no. its sqw.

>more precise, does the NX2016SA generate a sinus signal?

no. generates nothing - its a crystal.

>Is it true, that an external clock for the HSE would have to be a sinus signal?

no. see ds ->

AScha3_0-1701684157695.png

>Is it generally recommended to use an external clock instead of the oscillator

i use most times an ext. clock oszillator, nothing to worry about tuning caps etc. . ymmv.

>I did not order an external clock yet and thus, could not test it.

buy some and test. only way to know for sure.

i would try: (from mouser) 

520-2520MVLC-320CNTR  ; 32M, 1$ , 25ppm. drive at VCC about 1,6V , and cap + 75 r in series to cpu clk in.

"If you feel a post has answered your question, please click ""Accept as Solution""."
RWeil.2
RWeil.2Author
Associate III
December 4, 2023

Thanks for the information! Yes, a crystal does not generate a signal by itself but is used as a part of the oscillation circuit and driven by the microcontroller to generate an oscillating signal . Is this signal square wave or sinus?

Regarding the requirement for the HSE signal: I was using an older revision of the datasheet. Interesting how things change. 1,6 V (max.) Vpp means a signal from 0 V to 3,2 V (max.) should suffice, right? I would probably go for 3 V as voltage, because this is the voltage I use for the microcontroller.

RWeil2_0-1701685324165.png

Ok, then I will give an external clock oscillator a try. Do you have any data on the actual (not datasheet) startup time of the 520-2520MVLC-320CNTR?

Thanks!

 

AScha.3
Super User
December 4, 2023

>1,6 V (max.) Vpp means a signal from 0 V to 3,2 V (max.) should suffice, right?

no - is too much.  give 1,6V vcc to the oszillator, then it will output 1,6vss sqw. , thats according to ds.

 10nf + 75 ohm in series , so its AC coupled.

>Do you have any data on the actual (not datasheet) startup time

joking, eh ?   to know this, you have to test yourself.

at start/powerup , first cpu reset needs some ms , so i never worried about the osc. starting in 1ms or 2.

"If you feel a post has answered your question, please click ""Accept as Solution""."
LCE
Principal II
December 4, 2023

Interestingly, the WB series doesn't seem to support active oscillators. AFAIU it's because of the trimming which only works if the STM controls the complete feedback loop.

Anyway, concerning power consumption, from the MHz-oscillators that I know (even the MEMS-types, which are surprisingly good these days) I cannot imagine that you can save power with these, even if they have a faster start-up time.

RWeil.2
RWeil.2Author
Associate III
December 13, 2023

@LCE wrote:

Interestingly, the WB series doesn't seem to support active oscillators. AFAIU it's because of the trimming which only works if the STM controls the complete feedback loop.


Why do you think that?

 

RWeil2_1-1702469592939.png

 

 

 

RWeil.2
RWeil.2Author
Associate III
December 13, 2023

I did some more digging here https://community.st.com/t5/stm32-mcus-wireless/ble-sleep-mode-and-hse/m-p/615804#M17134

 

Unfortunately, ST has not responded yet. It seems that CPU2 also manages an external crystal and turns it on for advertising and off for sleep. But you cannot use an external clock when you want to advertise and benefit from the low power features. So regular advertising in low power mode only works with a crystal, as far as I understand it.

You can however, use an external clock during advertising, but then you have instead of ~300 uA average current the external clock current as well (which is about 3 mA with most clocks), because CPU2 cannot turn off your external clock. You could turn it off "manually" when you stop advertising e.g. for deep sleep mode or something, but there is no callback to do so during the advertising intervals.

AScha.3
Super User
December 13, 2023

so: end of the long story: use the crystal , as the chip is designed to use a crystal. :)

 

+

about calibration: you have no access to a SA ?

then i would try with a "certified" part : the max. distance, when connection is possible ;

when your crystal tuned some steps up or down, you should get a optimum max. distance - this should be the best fit to the "correct" frequency. 

"If you feel a post has answered your question, please click ""Accept as Solution""."
RWeil.2
RWeil.2Author
Associate III
December 18, 2023

@AScha.3 wrote:

about calibration: you have no access to a SA ?

then i would try with a "certified" part : the max. distance, when connection is possible ;

when your crystal tuned some steps up or down, you should get a optimum max. distance - this should be the best fit to the "correct" frequency. 


I bought a PFM3000. Well it´s not the most accurate one (+-8 ppm), but an affordable one. I output MCO on a pin and  tuned the HSE from 24,001000 MHz (HSECR = 00) to 24,000010 (HSECR = 48). SA will be purchased later.

I hoped I could avoid buying all that measurement equipment but a crystal really seems to be the better choice for now.