cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U575 Cannot Enter Stop mode and Retain SRAM3 with threadx

ASimo.3
Associate III

I have been trying for a while now to do something simular to this with threadx

https://community.st.com/t5/stm32-mcus/how-to-use-stm32u5-with-freertos-in-tickless-mode/tac-p/857701#M1715

I want to be able to put the MCU into STOP and wake from uart traffic,  I am using threadx not freertos.  I should note here that I have written a lot of code on the STM32U575 in the last couple years and have used threadx successfully quite a few times. Ultimately I want to add this to FW that is already running on a product so I would rather not change to freertos.   For the purposes of figuring this out I am working on the nucleo board.

The problem I am encountering is that the MCU never enters Stop at all unless I kill SRAM3.  As a sanity check I also tried doing this without an RTOS:

https://community.st.com/t5/stm32-mcus/how-to-wake-up-the-stm32u5-from-stop2-using-lpuart/ta-p/49436

Its the same thing as the first link just without freertos or my threadx adaptation.  It works fine!

 

So I took a step back and spent some time fooling around with this application example that ST includes and discovered some things:

https://github.com/STMicroelectronics/STM32CubeU5/blob/main/Projects/NUCLEO-U5A5ZJ-Q/Applications/ThreadX/Tx_LowPower/Src/app_threadx.c

The application from the Tx_LowPower example does indeed get to stop but kills almost everything: clocks, io, memory, etc!  However I have discovered that just by changing one Line I can get it to break in a way that it never enters stop and completely skips over the __WFI() macro

 

Any time the following code is called before calling HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);   The MCU will go into stop fine... this is also what is done in the above TX_lowPower application.. but if I understand it properly it nukes SRAM3 while preserving SRAM2

MODIFY_REG(RCC->AHB2ENR1, (0xFFFFFFFFU), RCC_AHB2ENR1_SRAM2EN );
MODIFY_REG(RCC->AHB2SMENR1, (0xFFFFFFFFU), RCC_AHB2SMENR1_SRAM2SMEN);

 

HOWEVER!!  If I comment those lines out OR change them to

MODIFY_REG(RCC->AHB2ENR1, (0xFFFFFFFFU), RCC_AHB2ENR1_SRAM2EN | RCC_AHB2ENR1_SRAM3EN);
MODIFY_REG(RCC->AHB2SMENR1, (0xFFFFFFFFU), RCC_AHB2SMENR1_SRAM2SMEN | RCC_AHB2SMENR1_SRAM3SMEN );

 

I can no longer enter stop mode.

Does anyone know the secret magic to entering stop mode while retaining SRAM3 using threadx?

 

 

 

 

0 REPLIES 0