cancel
Showing results for 
Search instead for 
Did you mean: 

Unnecessary hardfault due to button press on system wakeup pin.

JKSah
Associate II

We are trying to build a USB Data Logger We are facing some issue while being in run mode. Initially system is in standby mode and can be woken using button press (connected to system wakeup 1). On 5 sec press system/mcu starts logging data into flash memory at regular interval in which system goes to standby mode and wakes up from standby mode using RTC Alarm event and logs data. After some time when we are done logging we can stop the logging using same button press for 5 sec. This whole process is working fine but there is a issue, when we try to press button second time to stop logging there are 2 cases:

1) Button press while in between 2 logging while system is in standby mode: This works fine.

2) Button press while mcu is in run mode and trying to log data after wakeup: Here due to some issue system is going to hardfault whenever button is pressed in this mode even when button is not configured to execute any task in main loop or as interrupt.

After seeing all this we thought of checking this issue with fresh code with only led initialization and nothing else. We wrote a simple code of led blink pattern. In this case system was always in run mode. Again while led was blinking if we pressed the button connected to wakeup pin it sends the mcu to hard fault.

We tried same code blink code in nucleo l412rb-p board and no issue was there in that board. Kindly tell us what can be the issue.

Edit: No code is implemented in 2nd case for making the mcu to stop logging. It should just keep logging if the button is pressed in second case but instead it is going to hard fault. Also this hard fault only happen 60-70% times not always.

6 REPLIES 6
TDK
Guru

Attach a debugger to a board in the hard fault state and investigate the reason for the hard fault.

If you feel a post has answered your question, please click "Accept as Solution".

Start at what's actually faulting the register content, the pieces of code. While the narrative is interesting I don't think you're focusing on the cause.

Most likely you are making assumptions about structures/instances that are not fully initialized. You should add sanity checking to all pointers that you might be traversing, or callbacks/function-pointers that might be invoked, especially down IRQHandler call chains.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MM..1
Chief III

Hi try explain code how you check 5s press in case 2 run mode?

In second case actually we haven't implement that code for 5 sec press, just left the button configuration as uninitialised. Hence nothing should happen even if the button is clicked but still it is going in hard fault.

In second case actually we haven't implement that code for 5 sec press, just left the button configuration as uninitialised. Hence nothing should happen even if the button is clicked but still it is going in hard fault.

Even in simple led pattern code same thing is happening where button is uninitialised from start and mcu is always in run mode.​ User code includes gpio toggle and hal delay lines that's all.

​Also this only happen 60-70% times not always.

Focus on what's faulting, the MCU provide details, this is what's of interest to debug the situation...

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