cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L151RET6 use low power run cause hardfault

Barfield
Associate II

As title, MCU:STM32L151RET6, use freertos and enable tickless, when run  PreSleepProcessing(uint32_t *ulExpectedIdleTime) function sometimes, cause hardfault. the sleep para is PWR_LOWPOWERREGULATOR_ON.

but when use PWR_MAINREGULATOR_ON, it's run OK.

The mcu sysclk is RCC_MSIRANGE_6, about 4MHz.

This phenomenon occurs only on a few boards.

Trace code discovery the last code run configPRE_SLEEP_PROCESSING( &xModifiableIdleTime ) in the function __weak void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime ).

The performance is close to that of the substandard product?

__weak void PreSleepProcessing(uint32_t *ulExpectedIdleTime)
{
*ulExpectedIdleTime = 0;

// HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI);
}

 

1 REPLY 1
Barfield
Associate II

In functiion HAL_PWR_EnterSLEEPMode(), I changed 

if(SLEEPEntry == PWR_SLEEPENTRY_WFI)
{
/* Request Wait For Interrupt */
__WFI();
}

to

if(SLEEPEntry == PWR_SLEEPENTRY_WFI)
{
/* Request Wait For Interrupt */
__DSB();//add code
__WFI();
__NOP();//add code
__ISB();//add code
}

 

it worked normally.

if not change the code,and exchange two board's MCU, Every board works just fine. It looks like there's a difference in their performance.