cancel
Showing results for 
Search instead for 
Did you mean: 

I can't debug the file I want, how can I make the file I select debug without there being another file?

Gabriel1
Associate II

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.

8 REPLIES 8
Javier1
Principal

attach your code.

show us where in the stm32f4xx_it-c does your debugger stop, maybe in the hardfault handler?

we dont need to firmware by ourselves, lets talk
Gabriel1
Associate II

this is my code:0693W00000YAIXOQA5.pngbut when i debug it, it opens the c file that you see in the image below and it debugs that one not the main.c:

0693W00000YAIYMQA5.png 

I don't know if I have a wrong configuration or I don't know

I attached the file so you can see

thank you

That is the hardfault handler.

0693W00000YANSTQA5.png 

It means something went very wrong in your code

https://community.st.com/s/question/0D53W00000jmCPvSAM/whats-cause-of-hardfaulthandler-

we dont need to firmware by ourselves, lets talk
Gabriel1
Associate II

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:

0693W00000YAQlsQAH.pngYou can already see that the problem is indicating it to me but I don't know what to do to solve it.0693W00000YAQm2QAH.png

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 );

we dont need to firmware by ourselves, lets talk
Gabriel1
Associate II

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.

Bob S
Principal

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();

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.