stm32f4 hardfault
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-21 10:43 PM
hi
I use stm32f4 micro but an external interrupt pin
when i increase frequency of the external signal connected to interrupt pin, the micro jump to hardfault
why? how I can detect the solution?
- Labels:
-
STM32F4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-28 12:17 AM
how i can found it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-28 12:42 AM
char received_string_data[4];
Look at this https://www.tutorialspoint.com/c_standard_library/c_function_strncpy.htm
Your destination array size is less.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-28 4:07 AM - edited ‎2023-10-28 4:08 AM
>how i can found it?
A good question, thank you ))
The compiler should give a warning : warning: 'strncpy' writing 12 bytes into a region of size 4 overflows the destination [-Wstringop-overflow=]
But I've tested with several gcc versions on godbolt and was surprised that this warning shows up only starting with gcc v.12.something. Not in 11 and below, even with explicit -Wstringop-overflow option.
So ... Update to the latest gcc. If you cannot do this, use 3rd party tools for code analysis (which may be even better and robust).
Learn to debug. Like in other computer games, your character grows stronger and opens new skills when you play long enough))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-29 8:11 PM
i remove an 60000 byte array
why compiler does not warn or error when we use huge array in local functions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-29 8:40 PM
Neither the compiler or linker track call-stacks and stack usage, most of this occurs dynamically as the code runs, not a static allocation which the linker must fulfill.
You should not have more local/auto variables that exceed the available RAM under the stack pointer.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-30 2:45 PM
The received_string_data variable is global in that code, but that doesn't change the fact that the code writes beyond that buffer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-01 3:39 AM
the program hard fault ....
how I can solve ?
the my code has been attached!.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-01 9:16 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-03 8:29 PM
can every body check my code? or help me?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-11-03 10:29 PM - edited ‎2023-11-03 10:30 PM
Everyone explained to you what is wrong with your array. Think of it this way, you have a tennis ball container (array) that can only hold 3 tennis balls (values), max. You're basically trying to fit 4 or more balls into a container. So when you try to fit 4 balls in a container, all it's going to do is burst (hard fault).
So in your instance you're trying to put 5 or more values into an array that can fit only 4 values. Get the idea what's wrong now?
TimerCallback tutorial! | UART and DMA Idle tutorial!
If you find my solution useful, please click the Accept as Solution so others see the solution.
