Skip to main content
JHemb.1
Associate II
March 22, 2021
Solved

fix STM32f103 __WFI function gives hardfault_handler

  • March 22, 2021
  • 2 replies
  • 1409 views

Hello,

I enter stop mode using HAL_PWR_EnterSTOPMode and the processor come out of this function immediately and does not wait for any external interrupt. can someone help me on this?

This topic has been closed for replies.
Best answer by Tesla DeLorean

I had examples on the F1 a decade ago, kind of moved on since then.

You might want to glance over the assorted examples in the CubeF1 trees

STM32Cube_FW_F1_V1.8.2\Projects\STM32F103RB-Nucleo\Examples\RTC\RTC_Alarm

STM32Cube_FW_F1_V1.8.2\Projects\STM32VL-Discovery\Examples\PWR\PWR_SLEEP

STM32Cube_FW_F1_V1.8.2\Projects\STM32VL-Discovery\Examples\RTC\RTC_LowPower_STANDBY

2 replies

Technical Moderator
March 22, 2021

Hello @JHemb.1​ ,

Without entering stop mode, does the interrupt trigger?

Make sure to use latest release of STM32CubeF1 MCU package, and have a look to the errata sheet related to the STM32F103 devices, to check if you have the same conditions as described:

0693W000008xZ3eQAE.jpgPlease keep me informed about your progress on this.

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
JHemb.1
JHemb.1Author
Associate II
March 22, 2021

Hello ,

Thank you so much for your reply. We are using the stop mode and your solutions works for sleep mode. I want to wait for an interrupt when I enter HAL_PWR_EnterSTOPMode function. But I am not successfull in achieving this.

Tesla DeLorean
Guru
March 22, 2021

It doesn't have to be an external interrupt, could be any interrupt, so SysTick or whatever.

Also probably not something you want to single-step in a debugger.

Look at what's actually FAULTING, is it some other interrupt with expectation of structures being set up? A missing handler for a different interrupt, EXTI, RTC, or whatever?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
JHemb.1
JHemb.1Author
Associate II
March 22, 2021

Hello,

Thank you so much for your reply. In our case it is an external interrupt on pin PA10. My application should be like, When I am waiting for 2 or 3 minutes, then it should goto a Timer/RTC Alarm IRQ handler,

When we press the button on PA10, it should come out of the stop mode and also simultaneously come out of the IRQ handler.

Could you please provide any sample code or any reference which has a sample implementation?

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
March 22, 2021

I had examples on the F1 a decade ago, kind of moved on since then.

You might want to glance over the assorted examples in the CubeF1 trees

STM32Cube_FW_F1_V1.8.2\Projects\STM32F103RB-Nucleo\Examples\RTC\RTC_Alarm

STM32Cube_FW_F1_V1.8.2\Projects\STM32VL-Discovery\Examples\PWR\PWR_SLEEP

STM32Cube_FW_F1_V1.8.2\Projects\STM32VL-Discovery\Examples\RTC\RTC_LowPower_STANDBY

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..