cancel
Showing results for 
Search instead for 
Did you mean: 

High jitter on MCO output?

HWidj.2
Associate III

I just got my NUCLEO-H723ZG board, I loaded the GPIO_InfiniteLedToggling example project, downloaded the program to the board and it worked fine. Then I added a very simple code to output the HSE clock to an MCO pin.

/* Enable the MCO1 Clock */
  LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOA);
 
  /* Configure the MCO1 pin in alternate function mode */
  LL_GPIO_InitTypeDef   gpio_InitStruct;
  gpio_InitStruct.Pin = MCO1_PIN;
  gpio_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
  gpio_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
  gpio_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
  gpio_InitStruct.Pull = LL_GPIO_PULL_NO;
  gpio_InitStruct.Alternate = ((uint8_t)0x00);  // Alt. function = MCO.
  LL_GPIO_Init(MCO1_GPIO_PORT, &gpio_InitStruct);
 
  // Enable MCO1 (Source is HSE, 8 MHz, no prescaler).
  RCC->CFGR |= ((0x2 << RCC_CFGR_MCO1_Pos) | (0x0 << RCC_CFGR_MCO1PRE_Pos));

I inspected the clock output n the scope and I can see it's very jittery. I check the board schematic and found out that the HSE is a clock signal that is generated by a secondary MCU on the board which implements the ST-LinkV3 debugger, and in itself is an MCO signal. A 25MHz clock oscillator is attached to this secondary mcu and I guess the 8 MHz MCO signal is generated from this. I inspected this clock signal and it also has high jitter! The jitter is very bad, I've never even seen this much jitter from a clock signal generated by an internal RC oscillator.

I then enabled the LSE which uses the on-board 32KHz crystal as the source for the MCO output and saw that it also has considerable jitter, certainly not what I would expect coming from a clock signal generated by an external 32KHz crystal.

Is this something to be expected from an MCO output in STM32H7 devices?

10 REPLIES 10

> ST-LinkV3 debugger

It's known to output HSI clock onto its MCO. Search here in forum.

JW

Thanks for the info!

I'm still seeing significant jitter when using the on-board 32,768 crystal oscillator as the source for MCO though.

Henry

> I'm still seeing significant jitter when using the on-board 32,768 crystal oscillator as the source for MCO though.

How exactly do you do that?

Post content of relevant RCC registers.

JW

Here are contents of the relevant RCC registers:

RCC->CR = 0x03074025 (HSERDY, HSEON, HSEBYP all set, for system clock).

RCC->CFGR = 0x0040001B (LSE oscillator selected as source for MCO1)

RCC->BDCR = 0x00000003 (LSERDY set, LSEON set). 

RCC->AHB4ENR = 0x00000003 (Bus clock for GPIOA and GPIOB enabled for MCO pin). 

And here's a video showing the oscilloscope screen: https://www.mediafire.com/file/y6cs9betn390czr/VID20210610180555.mp4/file 

This sort of jitter may be normal with the LSE oscillator - it's a low power analog circuit resulting in relatively low amplitude oscillations, DC content of which does not necessarily need to be stable. There may be also impact from surrounding circuitry, ground, supply. Does the resulting count e.g. over 1 second deviate significantly from expected (i.e. 32768)?

You can also try to change the LSE drive in RCC_BDCR.

JW

Uwe Bonnes
Principal III

I have seen this jitter with HSE-> MCO on a G4. HSE is external 40 MHz oscillator, Core clock is 170 MHz. Jitter is about 5 ns. I suspect, GPIO is sampled by the core clock. I wonder however how this would work with CLOCK(MCO) > CLOCK(Core)?

I don't think the MCO's output is sampled. You can of course test this easily, as you've said, by changing the system clock's source.

Is the oscillator's jitter significantly lower than 5ns? How sharp are its edges (i.e. what's the rise/fall time)? If they are sharp, aren't there waveguide effects present (reflections)? Is the HSE set to BYPASS mode? How exactly is set the MCO in GPIO (mainly OSPEEDR)?

JW

HWidj.2
Associate III

Sorry, I have only had the time now to look at this issue again.

This turned out to be my fault. I've missed the note on the Reference Manual (RM0468) which states that the MCO source selection and prescaler selection should be made before enabling the oscillator and the PLL, otherwise glitches may be generated. Following this advice the jitter is largely gone and I got a stable clock output at the MCO pin.

Sorry, my fault. I looked at the signal after a digital isolator. The isolator is obvious injecting the jitter.