cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U535: SPI2 Stops Working When TRNG Enabled in CubeIDE

Badrinathan
Associate III

Hi @all  @stforum @stforum2  @stforum.tormod9  @stforum23 @jkn_stforum 

I’m using STM32U535CBTx MCU, using STM32Cube IDE.

Peripherals in use:

  • I2C1

  • UART4

  • LPUART1

  • SPI2

  • GPIO PB8, PB9, PB10 for LEDs

Issue:

 

  • SPI2 works fine when TRNG is disabled.

  • After enabling TRNG, SPI2 stops working.

I’ve attached both .ioc files (with TRNG enabled and disabled). Could someone please review them and suggest a solution?

Could anyone please:

  1. Review my .ioc files

  2. Explain why this happens and how to fix this issue?

  3. Suggest how to use TRNG and SPI2 together

I have attached two .ioc files for reference:

  1. sensor nodewith TRNG.ioc – this version has the TRNG peripheral enabled.

  2. sensor node without TRNG.ioc – this version does not use TRNG and SPI2 works correctly.

Please review and help identify why SPI2 stops working when TRNG is enabled.”

Thanks in advance!

6 REPLIES 6
Ghofrane GSOURI
ST Employee

Hello @Badrinathan 

I'm currently checking this behavior. I will get back to you asap.

THX

Ghofrane

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Badrinathan
Associate III

Hi @Ghofrane GSOURI 

Thanks, Ghofrane. I’ll wait for your update.

Thank you

Badrinathan J

Hello @Badrinathan 

I compared the two provided IOC files and identified the key differences in the clock configuration:

Without RNG:

The PLL is enabled and used as the system clock (SYSCLK).
MSI is selected as the PLL source.
SYSCLK is derived from the PLL, resulting in a higher system frequency.
Voltage scaling is set to SCALE1, providing the highest performance.
With RNG:

HSI48 (the 48 MHz internal oscillator, required for TRNG) is enabled.
The PLL is disabled (PLLState = RCC_PLL_NONE).
SYSCLK is sourced directly from MSI, not the PLL, leading to a much lower system frequency.
Voltage scaling is set to SCALE3, which is the lowest performance setting.
Recommendation:
To ensure both RNG and SPI2 function correctly, enable HSI48 for the RNG peripheral while maintaining your original PLL-based system clock and high-performance voltage scaling. This configuration will allow both peripherals to operate at their required speeds.

Please try this adjustment, and let me know the results.

PS: I used the latest version of CubeMX6.16.0 , you can download it from the following LINK

THX

Ghofrane

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Badrinathan
Associate III

Hello @Ghofrane GSOURI 

Thank you for your prompt response.

I would like to clarify that I am not using CubeMX .
I am configuring everything directly in STM32CubeIDE (latest version) using the .ioc file inside the Cube IDE. I am not manually changing the voltage scaling, but as soon as I enable the RNG, CubeIDE may be automatically switches the Voltage Scaling from SCALE1 to SCALE3

Could you please explain step-by-step how to correctly keep:

  • PLL enabled

  • SYSCLK sourced from PLL

  • Voltage Scaling = SCALE1

  • HSI48 enabled only for RNG

specifically inside STM32CubeIDE?

In this Cube IDE,  I am not sure where to set the voltage scaling back to SCALE1 or how to prevent CubeIDE from changing it automatically.

A detailed sequence of steps (menu paths, tabs, and settings) would really help me solve this using STM32 CubeIDE.

Thank you,
Badrinathan

Hello @Badrinathan 

Here are the steps I followed: I used CubeMX 6.16.0  standalone  and loaded your IOC file (sensor node without TRNG.ioc). I kept your original configuration, then activated the RNG and ensured that HSI48 is selected as the input for the RNG multiplexer. Afterward, I generated the code and chose STM32CubeIDE as the toolchain.

GhofraneGSOURI_1-1763386039256.png

 

GhofraneGSOURI_0-1763385953158.png

I will review this in STM32CubeIDE and get back to you.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hello @Badrinathan 

Inside STM32CubeIDE, import the attached IOC  

GhofraneGSOURI_2-1763387012151.png

Then generate code 

GhofraneGSOURI_3-1763387071880.png

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.