2023-02-06 06:25 PM
Hello, I have had a problem and it is that I make a simple program, in this case the blinking of the led of the "NUCLEO-F401RE" board and I use the gpio that comes by default. The point is that when I try to debug main.c, another file is opened (which is inside the same Src, called stm32f4xx_it.c) and that file is debugged and not main.c, which file has nothing .
I have tried closing and creating new projects, reinstalling the stm32 and closing and deleting the file every time it is opened and nothing works.
I'm new to this and any help would be very helpful.
2023-02-08 09:28 AM
attach your code.
show us where in the stm32f4xx_it-c does your debugger stop, maybe in the hardfault handler?
2023-02-08 01:38 PM
2023-02-09 06:50 AM
That is the hardfault handler.
It means something went very wrong in your code
https://community.st.com/s/question/0D53W00000jmCPvSAM/whats-cause-of-hardfaulthandler-
2023-02-09 09:17 PM
I already understood about hardfault, but I don't know how to modify the registry or how to solve it, since as you can see there are 2 lines of code.
I checked the Faul analyzer and this is what it gives me:
You can already see that the problem is indicating it to me but I don't know what to do to solve it.
2023-02-10 12:32 AM
Just debug step by step and figure out which line of code triggers the fault handler.
>>NUCLEO-F401RE
If youre using a nucleo board we can rule out hardware issues.
also i believe "GPIO_PIN_5" is not defined anywhere , you just tried your luck there. try this: (after looking in "main.h" defines)
Instead of
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
do
HAL_GPIO_TogglePin(LD2_GPIO_Port , LD2_Pin );
2023-02-10 12:28 PM
I have declared PA5 in the visual part, but even so, I tried what you suggested and still, the error enters.
I tried to do it step by step, but it's just hitting debugin and the error comes in, I can't even give it a stop or summary step.
2023-02-10 02:25 PM
On the STM32F4xx family (and possibly others, I don't recall off the top of my head), the USAGE FAULT, BUS FAULT and MEMORY MANAGEMENT FAULT are disabled by default. If you get any of those faults when they are disabled, the ARM code core will escalate the fault to a HARD FAULT.
So try enabling these faults. You probably don't need the MEMMANAGE fault enabled since you aren't (yet) using it. Add this at the start of main() before any other code, including HAL_Init().
// WARNING: Hand typed, not copy/paste from actual code, may have typos
__DSB(); // DSB and ISB may not be needed on the M4 cores, but doesn't hurt
__ISB();
SCB->SHCSR |= (SCB_SHCSR_USGFAULTENA_Msk | SCB_SHCSR_BUSFAULTENA_Msk | SCB_SHCSR_MEMFAULTENA_Msk);
__DSB();
__ISB();
2023-02-10 04:03 PM
I just did what you suggested and I keep getting the error. I even deleted and reinstalled to see if it worked for me and I hit debugin without putting anything, that is, I created the project and then I gave it debugin and even so I get the error without writing or configuring anything.