的ARM Cortex M3如何确定一个硬件故障前的程序计数器值? [英] ARM Cortex M3 How do I determine the program counter value before a hard fault?

查看:336
本文介绍了的ARM Cortex M3如何确定一个硬件故障前的程序计数器值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是STM32F103(的ARM Cortex M3),是越来越嵌入式项目越来越偶尔在释放模式硬件故障。作为恢复的一部分,我想从硬盘故障前获取的PC值,并将其存储在电池供电的区域后调试。

I have an embedded project using a STM32F103 (ARM Cortex M3), it is getting a occasionally getting hard fault in release mode. As part of recovery, I would like to retrieve the PC value from before the hard fault and store it for later debugging in the battery backed region.

我将如何确定在硬故障点的程序计数器的值?显然,PC现在设置它的位置在hardfault中断之内。

How would I determine the value of the program counter at the point of the hard fault? Obviously, the PC is now set to its location within the hardfault interrupt.

我应该在哪里看?它有一个地址,在正常模式寄存器组?

Where should I look? It there an address for the normal mode register bank?

谢谢!

推荐答案

Cortex-M3的异常使用从经典ARM,例如处理一个完全不同的模式它并没有在其他文章中提到中止模式。我建议你​​阅读本应用笔记。例如,对于硬故障:

Cortex-M3 uses a quite different model of exception handling from the "classic" ARM, e.g. it doesn't have "abort mode" mentioned in the other post. I suggest you to read this app note. For example, for the Hard Fault:

SCB-的值> BFAR表示引起了总线故障的内存地址
  如果在SCB-> CFSR寄存器中的位BFARVALID设置是有效的。该
  SCB-> MMFAR的值表示引起了内存的内存地址
  管理故障是有效的,如果该位MMFARVALID在SCB-> CFSR
  寄存器设置。

The value of SCB->BFAR indicates the memory address that caused a Bus Fault and is valid if the bit BFARVALID in the SCB->CFSR register is set. The value of SCB->MMFAR indicates the memory address that caused a Memory Management Fault and is valid if the bit MMFARVALID in the SCB->CFSR register is set.

要确定例外的,你需要检查堆栈时,PC值;处理器执行处理程序之前推R0-R3,R12,PC和LR。使用的堆栈可以是主要(如果LR的第2位为0)或进程(否则)。有关详细信息,请参阅应用手册第13页。

To determine the PC value at the time of exception you need to examine the stack; the processor pushes R0-R3, R12, PC and LR before executing the handler. The stack used can be either Main (if bit 2 of LR is 0) or Process (otherwise). See page 13 of the app note for details.

这篇关于的ARM Cortex M3如何确定一个硬件故障前的程序计数器值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆