当前位置:网站首页>STM32 hardware error hardfault_ Handler processing method
STM32 hardware error hardfault_ Handler processing method
2022-06-25 17:04:00 【Lixiaoyao】
Focus on 、 Official account of star standard , Straight to the highlights
source : Network material
In use Keil Yes STM32 Sometimes the program will fly when the program is simulated , Stopping the emulator will stop at HardFault_Handler Loop in function while(1) in . This explanation STM32 A hardware error has occurred .

STM32 Hardware errors can occur for the following reasons :
(1) Array out of bounds operation ;
(2) out of memory , Cross border visit ;
(3) stack overflow , The program flies ;
(4) Interrupt handling error ;
In this case , You can use the following 2 Two ways to locate the error code segment .
Method 1:
1.1 Interrupt function in hardware HardFault_Handler Inside while(1) Place debugging breakpoints , When the program reaches the breakpoint, click “STOP” Stop simulation .

1.2 stay Keil Menu bar click “View”——“Registers Window”, Look in the register view window R14(LR) Value . If R14(LR) = 0xFFFFFFE9, Keep looking at MSP( Main stack pointer ) Value , If R14(LR) = 0xFFFFFFFD, Keep looking at PSP( Process stack pointer ) Value . My program R14(LR) = 0xFFFFFFF9, Next, take this as an example .

1.3 stay Keil Menu bar click “View”——“Memory Windows”——“Memory1”, stay “Address” Enter... In the address field MSP Value :0x20001288, Then find the address in the corresponding line . The address is usually in 0x08 At the beginning 32 digit . In this case , The address is 0x08003CB9.

1.4 stay Keil Menu bar click “View”——“Disassembly Window”, stay “Disassembly” Right click in the window , Select from the drop-down menu “Show Disassemblyat Address...”. In the pop-up box “Show Code atAdress” Enter the address in the address box of 0x08003CB9 To search , Then you will find the corresponding code . The code here is the case before entering the loop interrupt . Check the relevant codes in the nearby area to find out the specific cause of the error .

Method 2:
2.1 Interrupt function in hardware HardFault_Handler Inside while(1) Place debugging breakpoints , When the program reaches the breakpoint, click “STOP” Stop simulation .

2.2 stay Keil Menu bar click “View”——“Call Stack Window” eject “Call Stack + Locals” Dialog box . Then right click in the dialog box and select “Show Caller Code”, Will jump to the function before the error , Check carefully the function being called or the memory usage of the array .
Link to the original text :https://blog.csdn.net/electrocrazy/article/details/78173558
Copyright notice : Source network of this paper , Free delivery of knowledge , The copyright belongs to the original author . If involves the work copyright question , Please contact me to delete .
‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧ END ‧‧‧‧‧‧‧‧‧‧‧‧‧‧‧
Pay attention to my WeChat official account , reply “ Add group ” Join the technical exchange group according to the rules . Click on “ Read the original ” See more sharing , Welcome to share 、 Collection 、 give the thumbs-up 、 Looking at .边栏推荐
猜你喜欢
随机推荐
About: encryption and decryption of rsa+aes data transmission [chapter], project practice (special summary)
远程终端控制神器——MobaXterm
Notes: lbcf: a Large Scale budget Constrained causal Forest Algorithm
Kotlin
uniapp实现图片(单张/多张)预览
TCP chat + transfer file server server socket v2.8 - fix 4 known problems
internship:Swagger下注解的涉及 接口的提供
项目经理在项目中起到的作用
心情
从业一年,我是如何涨薪13K+?
剑指 Offer 50. 第一个只出现一次的字符
2022-06-17 网工进阶(九)IS-IS-原理、NSAP、NET、区域划分、网络类型、开销值
Why does MySQL limit affect performance?
mac php多版本管理以及安装swoole扩展
WPF开发随笔收录-心电图曲线绘制
论文笔记:Generalized Random Forests
Wechat official account server configuration
【精通高并发】深入理解C语言基础与汇编下的C语言
Generate post order traversal according to pre order traversal and mid order traversal
XXIX - orbslam2 real-time 3D reconstruction using realsensed435









