32F4 - is there a spec on the 50MHz clock from the ETH PHY? - Page 1
Forum section: electronics / general

author: peter-h
author_rank: Super Contributor
timestamp: October 05, 2022, 09:56:40 am
content: I have a fairly standard LAN8742 driving a 50MHz clock to the 32F417.The 32F417 is producing a 25MHz clock to the PHY and that doubles it and sends it back to the 32F417.All the schematics around have a 22R resistor in that 50MHz track. Mine is about 5cm long and I did the same, so the value can be tweaked if necessary.The signal out of the 8742 is a super clean square wave - very good for 50MHz (10ns/div on a 350MHz scope)but after the 22R it isn't so great (but everything works)I would imagine this 50MHz goes into a logic gate and gets squared up. The risetime is about 2ns and that includes the scope, so it looks fast enough. But I can't find a spec for this anywhere.The tradeoff is EMC; a sharp 50MHz signal going around the place is not a good idea. The track before the 22R is only about 10mm long.

author: paulca
author_rank: Super Contributor
timestamp: October 05, 2022, 10:50:48 am
content: 50Mhz is pretty non trivial RF. I think when they start putting ** notes on the pinout diagram it means they are serious about the track length and probably that track will need careful routing and maybe capacitance protection with ground guards. Although I'm not an expert in any of that.I'm going to assume you have to do it this way for the ETH PHY, because doesn't the STM32 normally take a low but highly accurate HSE signal like 8Mhz and multiply it up to get to FCLK via the PLL? Doing so lowers the requirements on RF circuitry.I know on even smaller MCUs with 20Mhz clocks the crystal and load caps were always placed right beside the xtl pins to minimise capacitance issues.

author: peter-h
author_rank: Super Contributor
timestamp: October 05, 2022, 02:20:54 pm
content: I've been looking for a spec for the input signal onETH_RMII_REF_CLK-------> PA1which is 50MHz.

author: wek
author_rank: Frequent Contributor
timestamp: October 05, 2022, 03:00:15 pm
content: STM32F417 DS,Dynamics characteristics: Ethernet MAC signals for RMIITable.Match that with the PHY's specs plus any delay/skew/whatever you have on the signals.JW

author: peter-h
author_rank: Super Contributor
timestamp: October 05, 2022, 03:10:05 pm
content: I saw that, but there is no spec on the clock "quality".That slower clock may be delaying the effective clock by ~1ns. I can check the data hold time etc, though not easily because I have onlyone0.9pF 1GHz ZS1000 probe; they are >£1k

author: nctnico
author_rank: Super Contributor
timestamp: October 05, 2022, 04:00:30 pm
content: The 50MHz coming from the PHY doesn't have much of a sharp edge to begin with. I'd replace the 22 Ohm resistor with a 0 Ohm resistor and increase it if it turns out to be a problem.I'd be more worried about the ethernet side of the PHY leaking RF (multiples of 125MHz) into the ethernet cable. Power supply filtering, power distribution (plane or fat traces) and decoupling of the analog side of the PHY is very important. My goto solution when using low-costs PHYs is to add resistors (ballpark 3 OHm) or ferrite beads in series with the ethernet lines. A bead like 10 Ohm @100 MHz but you need to check the graph for the bead to see how it behaves; for this purpose the peak impedance of the bead should be far beyond 100MHz. Again, tweaking the value in case of trouble passing EMC testing is a good idea.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 05, 2022, 05:12:13 pm
content: What's the problem?

author: wek
author_rank: Frequent Contributor
timestamp: October 05, 2022, 06:14:55 pm
content: QuoteI don't know what "clock quality" means.This is a normal digital input as any other. You have thresholds and hysteresis specd in the same DS inI/O static characteristicstable. From those and the slopes of your signal calculate min and max sampling point. Hysteresis is to remove effects of noise.JW

author: peter-h
author_rank: Super Contributor
timestamp: October 05, 2022, 07:09:19 pm
content: QuoteI am using the RJ45 with integrated magnetics (Hanrun HR911105A) which should help quite a lot with EMC.QuoteIt's as sharp as I am gonna get on a 350MHz DSOHowever, on a Tek 2465B 400MHz analog scope and a Tek P6201 FET probe (1.5pF) it looks like this and is almost identical on both ends of the 22R resistorQuoteThere isn't; I am just making sure I have margins

author: nctnico
author_rank: Super Contributor
timestamp: October 05, 2022, 07:14:51 pm
content: Quote from: wek on October 05, 2022, 06:14:55 pmTypically: frequency accuracy, rise/fall time, jitter, duty cycle and amplitude are the parameters that are relevant for a clock signal.

author: nctnico
author_rank: Super Contributor
timestamp: October 05, 2022, 07:18:40 pm
content: Quote from: peter-h on October 05, 2022, 07:09:19 pmFamous last words...It would not be the first time an ethernet interface fails even with such a connector. You better make sure you have the option to include series resistors and capacitors to ground on the signal lines. If EMC fails, you can fix it quickly without a board respin.

author: srb1954
author_rank: Super Contributor
timestamp: October 05, 2022, 08:50:43 pm
content: Quote from: peter-h on October 05, 2022, 07:09:19 pmAm I seeing the occasional bit of jitter on the analog scope trace or it just an imperfection in the scope set-up?If it is jitter this might be more critical as it could affect timing margins on the internal data recovery circuitry giving rise to errors in received data.Check the clock signal again with your DSO in infinite persistence mode to see if jitter is present.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 05, 2022, 09:03:25 pm
content: Was going to say, that rounding could just be probe capacitance. But the FET probe follow-up seems to confirm that.Tim

author: wek
author_rank: Frequent Contributor
timestamp: October 05, 2022, 09:07:32 pm
content: Quote from: nctnico on October 05, 2022, 07:14:51 pmThanks.In this particular case, the ETH MAC in STM32 does not care about any of these (well maybe amplitude and rise/fall times - through the decision levels), as long as the timing relationship between clock edges and Rx signal edges are according to the timing table in the STM32 DS. The MAC is a synchronous machine driven by this clock. Heck, it even does not care whether it's 50MHz or not. And again, it will spit out Tx signals towards PHY according to the timing table, related to the clock edges.So, as long as those parameters given by DS are maintained, MAC will work perfectly OK.JW

author: peter-h
author_rank: Super Contributor
timestamp: October 05, 2022, 09:12:41 pm
content: QuoteThe "jitter" is not really there; the phone picked that up because it was over-exposed, or the trigger level was marginally set. I had a lot of trouble getting that pic while probing a tiny spot on the board.QuoteBoth probes are FET probes and I would expect the 1GHz £1600 LeCroy 0.9pF one to have less of an effect than the Tek 1.5pF one. I have just looked around the LC scope config and can't see any config for the probe, so this is a mystery.I am much more inclined to trust the analog Tek scope.QuoteThat's a new one!

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 05, 2022, 09:36:17 pm
content: Quote from: peter-h on October 05, 2022, 09:12:41 pmOh... that is mysterious, huh.Tim

author: nctnico
author_rank: Super Contributor
timestamp: October 05, 2022, 10:01:15 pm
content: Quote from: peter-h on October 05, 2022, 09:12:41 pmIn theory that is true. I have software bit-banged a MAC interface in some of my projects. However, it is possible a chip uses the absence of an external clock as a reason to produce an internal clock. In such a case the external clock frequency does matter.

author: wek
author_rank: Frequent Contributor
timestamp: October 05, 2022, 10:13:07 pm
content: Quote from: nctnico on October 05, 2022, 10:01:15 pmNot this one. The ETH/MAC in STM32 is known to be "frozen" when the external clock is not present.Quote from: peter-h on October 05, 2022, 09:12:41 pmWhy? It's not that much different from SPI, for example, as long as the clock-to-signal relationship goes. At the end of the day, MAC is also only a pair of shift registers (okay, a somewhat weird 2-bit variant), plus an extremely complicated loading/unloading machine.That PHY won't be happy and other parties on the net won't talk to it, is a different thing.JW

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 05, 2022, 10:26:02 pm
content: AFAIK the STM32F4 have Schmitt trigger on all inputs, so it shouldn't make a difference as long as the signal is not badly asymmetric.

author: peter-h
author_rank: Super Contributor
timestamp: October 06, 2022, 01:32:43 pm
content: There is some dodgy stuff going on because the LAN8742 generates the 50MHz from the 25MHz, and how do you do that? With some funky logic and tweaked gate delays?I would think the 50MHz is needed for 100mbps ETH - simple? How else could you do 100mbps? And the LAN8742 must be generating a 100MHz internal clock, no?

author: wek
author_rank: Frequent Contributor
timestamp: October 06, 2022, 01:45:20 pm
content: Quote from: wikipediahttps://en.wikipedia.org/wiki/Fast_Ethernet#CopperJW

author: hans
author_rank: Super Contributor
timestamp: October 06, 2022, 04:30:12 pm
content: Where is the 25MHz coming from? The PLL of the STM32F4 chip? IIRC the PLL of the STM32F4 has quite a lot of jitter. I'm not sure if it's enough to cause issues, but I remember reading about it when I had issues trying to use it for an ethernet phy.For example, the LAN8742 requires 150ps p-p jitter (not RMS) MAX @ 50MHz.The STM32F4 has a cycle-to-cycle jitter of 32ps jitter at 50MHz and 40ps jitter at 25MHz. However, this is "TYP", and it's unclear where it's p-p or RMS. For what it's worth, the period jitter @ 120MHz is 200ps p-p and 15ps RMS, which are all lower values (logically) because the period time is much shorter.So judging from this data, I suspect the listed spec @25M is RMS jitter, and that the p-p jitter is in the order of 500ps p-p. Can't recommended to use it for anything besides diagnostic or asynchronous.

author: wek
author_rank: Frequent Contributor
timestamp: October 06, 2022, 04:47:50 pm
content: Quote from: hans on October 06, 2022, 04:30:12 pmThis is why the 'F4xx DS recommend not to use PLL as clock source for ETH PHY.JW

author: peter-h
author_rank: Super Contributor
timestamp: October 06, 2022, 10:07:29 pm
content: The above is the circuit I am using. It is also what ST use on their dev board.The 25MHz comes from the 32F4 and goes to the LAN8742, which then sends back a 50MHz waveform to the 32F4.So the LAN8742 contains a PLL to double the frequency.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 07, 2022, 03:31:47 am
content: The point was not that a PLL could not be used for this. PLLs are routinely used for very low jitter stuff. It's just that apparently the PLL in the STM32F4 itself is crappy.I'm sure the LAN8742's PLL has proper characteristics.

author: nctnico
author_rank: Super Contributor
timestamp: October 07, 2022, 07:45:10 am
content: Likely the pll inside the STM32 is based on an adjustable digital delay line with fixed intervals instead of a VCO. Such digital PLLs alway produce huge amounts of jitter ( up to 100s of ps)

author: wek
author_rank: Frequent Contributor
timestamp: October 07, 2022, 08:32:30 am
content: QuoteSure, all analog features on STM32 are crappy when compared to ideals. But as this is not just an arduino chitchat, can we appreciate how well they work being mixed with raging digital, and how good value for the eurocent they are?QuoteBuilding a single-frequency PLL is "easy".QuoteNot on the EVAL... oh, quite aridethat one was...JW

author: peter-h
author_rank: Super Contributor
timestamp: October 07, 2022, 08:52:38 am
content: QuoteThat makes much more sense, given that 50MHz is all that's ever needed.Good to know I am not doing it wrongI have ~15 boards now working solidly.QuoteDo you mean anything specifically? Sure, all ADCs and DACs on CPUs are "crap". I've never seen one on which the last couple of bits weren't noise.From the ST forum post:QuoteI don't mean to sound like a smart arsebut I would never use a 50MHz oscillator because of the EMC issue. And yes the ST dev kit runs signals for miles around the place. They are CE (EMC) exempt so they can do it.I also don't like Abracon as a company. If I am going to pay top dollar I make sure I get a premium part e.g. Kyocera, AVX, etc.

author: nctnico
author_rank: Super Contributor
timestamp: October 07, 2022, 09:59:36 am
content: NXP's LPC series has good ADCs. I even had trouble to make these more noisy to get a few more bits out of them.About the clock: on a 4 layer board with a solid ground plane it is almost impossible to screw up a layout where it comes to EMC compliance.