2024-01-14 04:24 PM
Struggling to get my own STM32U5A5 board working... the USB HS PHY was not working, until... (see below).
I was confused also with this thread:
https://community.st.com/t5/stm32-mcus-products/stm32u5-and-usb-hs/td-p/571774
This told me actually as well: you need an external XTAL, not a CMOS OSC (and maybe 16 MHz). - But not true.
I have changed my SystemClock_Config() !
Instead of an external 16 MHz XTAL (as on NUCLEO-U5A5ZJ-Q board) I have an external 8 MHz CMOS OSC (not a XTAL).
The USB CDC (VCP UART) project, running on NUCLEO board - runs now also on my own PCB! Cool.
Some other tweaks needed to reuse my NUCLEO-U5A5JZ-Q project (e.g. no UCPD1, no ADC VBUS sensing), but this SystemClock_Confing() did the job:
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE;
#ifdef NUCLEO_BOARD
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
#else
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
#endif
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMBOOST = RCC_PLLMBOOST_DIV1;
#ifdef NUCLEO_BOARD
//16 MHz XTAL, NUCLEO board
RCC_OscInitStruct.PLL.PLLM = 1;
RCC_OscInitStruct.PLL.PLLN = 20;
RCC_OscInitStruct.PLL.PLLP = 10; //32 MHz needed here!
RCC_OscInitStruct.PLL.PLLQ = 2;
RCC_OscInitStruct.PLL.PLLR = 2;
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLLVCIRANGE_1;
#else
//8 MHz OSC, my board
RCC_OscInitStruct.PLL.PLLM = 1; //2; ==> THIS FAILS on USB
RCC_OscInitStruct.PLL.PLLN = 40; //20; ==> THIS FAILS on USB
RCC_OscInitStruct.PLL.PLLP = 10;
RCC_OscInitStruct.PLL.PLLQ = 2;
RCC_OscInitStruct.PLL.PLLR = 2;
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLLVCIRANGE_1;
#endif
So, I can confirm: U5A5 works also with an 8 MHz CMOS OSC, instead of a XTAL (as mentioned in datasheet).
Just: not all possible combinations for PLL settings work, just one particular one.
Solved! Go to Solution.
2024-01-15 10:05 AM
Yes, for USB HS on a STM32U5A5 (the one with internal HS PHY) it "must" be external HSE. But not as mentioned just via a XTAL. It can be also a CMOS OSC chip (I use).
The confusion was on the statement in datasheet as:
"This interface requires a precise 60 MHz clock that is generated from the internal
USB PHY PLL (the clock source must use a HSE crystal oscillator)."
So, use HSE and enable HSE as clock source for the PLLs. And it works also with single-pin clock chip.
2024-01-14 05:38 PM
2024-01-14 05:51 PM
> RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
You're still using an external clock source. You didn't give the part number or I'd check but likely it's driven internally by a crystal. The STM32 doesn't know or care where the clock comes from, as long as it's sufficiently accurate. External oscillators can be plenty accurate here.
The linked post is saying HSI is not suitable for HS USB, which is accurate.
2024-01-15 10:05 AM
Yes, for USB HS on a STM32U5A5 (the one with internal HS PHY) it "must" be external HSE. But not as mentioned just via a XTAL. It can be also a CMOS OSC chip (I use).
The confusion was on the statement in datasheet as:
"This interface requires a precise 60 MHz clock that is generated from the internal
USB PHY PLL (the clock source must use a HSE crystal oscillator)."
So, use HSE and enable HSE as clock source for the PLLs. And it works also with single-pin clock chip.
2024-01-18 07:35 AM
Yes, if you use an external oscillator, which meets the USB HS 100ppm tolerance requirements, everything is going to work fine. Btw such an oscillator will have a crystal inside.
The original discussion was about using the internal RC oscillators, which don't get better than maybe 1000ppm.
You also have to be careful not to use an external RC resonator - that would also not work for USB HS, as their tolerances are much higher than 100ppm.
2024-01-18 09:32 AM
Thank you.
The OSC I use (MC2520Z8.00000C19XSH) has a tolerance of 30ppm.
It looked to me the issue was the PLL setting: