hardfault常见原因_XMC实验分享之四十八: Cortex M0的Hard Fault发生原因

凡是在Cortex M系列内核上写过程序的程序员, 没有不知道Hard Fault的. 大多数程序出现问题的表现就是进入Hard Fault.

但是进入Hard Fault的原因是甚么, 为了查明这个问题, 不少程序员为之废寝忘食...

Hard Fault的设计初衷就是为了程序出错之后提供一个预警机制, 但是进入Hard Fault的原因有很多. 所以把这个问题研究透对调试排错意义很大.

相比于其他型号, Cortex M0只有一种Fault就是Hard Fault. 本帖以几个实验稍稍探究一下子发生Fault的原因.

首先看手册, Cortex M0发生Hard Fault的原因有如下几种:

Faults are a subset of exceptions, see Exception model on page 2-19. All faults result in

the HardFault exception being taken or cause lockup if they occur in the NMI or

HardFault handler. The faults are:

? execution of an SVC instruction at a priority equal or higher than SVCall

? execution of a BKPT instruction without a debugger attached

? a system-generated bus error on a load or store

? execution of an instruction from an XN memory address

? execution of an instruction from a location for which the system generates a bus fault

? a system-generated bus error on a vector fetch

? execution of an Undefined instruction

? execution of an instruction when not in Thumb-State as a result of the T-bit being previously cleared to 0

? an attempted load or store to an unaligned address.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值