初级会员
- 积分
- 79
- 金钱
- 79
- 注册时间
- 2018-6-28
- 在线时间
- 14 小时
|
1金钱
看火哥的书目前第六章已经快完了,这里有几个疑惑?1.汇编文件context_rvds.S中 需要导入rt_hw_hard_fault_exception函数,目前这个函数还没有写,现在汇编文件中将其注释。
仿真出来的波形如下:
不知道这样会有什么影响吗?
打开RT-thread源码,在rthw.h文件中找到了rt_hw_hard_fault_exception 函数 定义如下:
[mw_shl_code=c,true]void rt_hw_hard_fault_exception(struct exception_info * exception_info)
{
extern long list_thread(void);
struct stack_frame* context = &exception_info->stack_frame;
if (rt_exception_hook != RT_NULL)
{
rt_err_t result;
result = rt_exception_hook(exception_info);
if (result == RT_EOK)
return;
}
rt_kprintf("psr: 0x%08x\n", context->exception_stack_frame.psr);
rt_kprintf("r00: 0x%08x\n", context->exception_stack_frame.r0);
rt_kprintf("r01: 0x%08x\n", context->exception_stack_frame.r1);
rt_kprintf("r02: 0x%08x\n", context->exception_stack_frame.r2);
rt_kprintf("r03: 0x%08x\n", context->exception_stack_frame.r3);
rt_kprintf("r04: 0x%08x\n", context->r4);
rt_kprintf("r05: 0x%08x\n", context->r5);
rt_kprintf("r06: 0x%08x\n", context->r6);
rt_kprintf("r07: 0x%08x\n", context->r7);
rt_kprintf("r08: 0x%08x\n", context->r8);
rt_kprintf("r09: 0x%08x\n", context->r9);
rt_kprintf("r10: 0x%08x\n", context->r10);
rt_kprintf("r11: 0x%08x\n", context->r11);
rt_kprintf("r12: 0x%08x\n", context->exception_stack_frame.r12);
rt_kprintf(" lr: 0x%08x\n", context->exception_stack_frame.lr);
rt_kprintf(" pc: 0x%08x\n", context->exception_stack_frame.pc);
if(exception_info->exc_return & (1 << 2) )
{
rt_kprintf("hard fault on thread: %s\r\n\r\n", rt_thread_self()->name);
#ifdef RT_USING_FINSH
list_thread();
#endif /* RT_USING_FINSH */
}
else
{
rt_kprintf("hard fault on handler\r\n\r\n");
}
#ifdef RT_USING_FINSH
hard_fault_track();
#endif /* RT_USING_FINSH */
while (1);
}[/mw_shl_code]
|
最佳答案
查看完整内容[请看2#楼]
这个注释掉没什么关系,因为正常跑的时候,并不会去触发fault。只有当程序跑挂掉的时候才会进入到fault处理流程。
而 rt_hw_hard_fault_exception 函数也是为了尽可能多的dump一些信息,辅助分析问题点在哪里。
|