cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Serial Interrupts Crash

jdp6q5
Associate II
Posted on April 09, 2013 at 19:01

The original post was too long to process during our migration. Please click on the attachment to read the original post.
5 REPLIES 5
Posted on April 09, 2013 at 20:22

Yeah, sounds like you're ending up in the Hard Fault routine. You might want to add a real handler there to ascertain why it's faulting.

You should really set up the NVIC side before enabling the interrupts.

Your range checking for the buffers is broken. Tip: operator precedence

If you're using C++, make sure that the vector table is actually pointing to your USARTx_IRQHandler() functions, and not dumping the processor into the while(1) tied to the unhandled interrupts. Check the function names in the .MAP file. Check the address for the routines in the vector table from within the debugger.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jdp6q5
Associate II
Posted on April 10, 2013 at 14:25

I understand most of that. I forgot to mention this is my first ARM board. I'm coming from the 8 bit AVR world where you usually don't deal with startup files and such. Are there any good tutorials anyone knows of on startup files? I'm having trouble finding one. I know the startup file mentions that it maps the default interrupt handler to all interrupt routines with the .weak option, but that another definition should override that. Maybe not? Also, I'm trying to figure out how to use GDB to check if my vectors are mapped correctly. I've used GDB before, but not for embedded targets. I usually use it to track down segfaults in C++ programs for the x86.  I'll post on my progress when I make some

dthedens23
Associate II
Posted on April 10, 2013 at 18:48

Sure, there is the whole CMSIS documentation.  But what is really important is the startup files for your particular part or family of parts.  The startup is part specific.  These should be in include files and lib files somewhere in your project.

jdp6q5
Associate II
Posted on April 10, 2013 at 19:46

Looking through the map file,  the USART6_IRQHandler function is generated, but is not loaded into the vector table. In the startup file,

there are a bunch of lines which say

.weak XXX_IRQHandler

 

.thumb_set XXX_IRQHandler, Default_Handler

 

 

If I leave these alone, the USART3 and 6 handlers get mapped to the default handler. If I comment out the .thumb_set line, I don't see the USART interrupt handlers inserted anywhere in the vector table. Its almost like the linker isn't paying attention to my functions and placing them in the interrupt table.

jdp6q5
Associate II
Posted on April 19, 2013 at 02:23

Took me  a lot of looking, but I finally found the problem. I must have accidentally started a new c++ project when I made the project. My main file was named main.cpp instead of main, so the linker was just grabbing the default handler instead. I noticed this when I moved some of my own code to a separate C file and the linker couldn't figure it out.  Thanks for the tips