我现在用CodeSourcery+jlink+openocd开发stm32
平台:stm32f103zet6
flash:内置512K(大容量)
sram:内置64K+外部512K
启动文件:startup_stm32f10x_hd.c
链接脚本:stm32f10x_flash_extsram.ld
程序一执行80行的除法运算就进入硬中断,这是怎么回事呢?
相关部分如下:
UINT32 m;
Breakpoint 2, Task_Start (p_arg=0x0) at main.c:80
80 m = 72000000 / 16; //把72000000改小变成例如32就OK, 这是什么情况?
(gdb) n
^C
Program received signal SIGINT, Interrupt.
HardFault_Handler () at stm32f10x_it.c:64
64 {}
我查看了汇编代码:
Breakpoint 2, Task_Start (p_arg=0x0) at main.c:80
80 m = 72000000 / 16;
=> 0x08000a30 <Task_Start+40>: 4f f0 02 03 mov.w r3, #2
0x08000a34 <Task_Start+44>: fb 60 str r3, [r7, #12]
(gdb) ni
0x08000a34 80 m = 72000000 / 16;
0x08000a30 <Task_Start+40>: 4f f0 02 03 mov.w r3, #2
=> 0x08000a34 <Task_Start+44>: fb 60 str r3, [r7, #12]
(gdb) ni
81 16;
=> 0x08000a36 <Task_Start+46>: f8 68 ldr r0, [r7, #12]
0x08000a38 <Task_Start+48>: 13 f0 46 ed blx 0x80144c8 <__floatunsidf>
0x08000a3c <Task_Start+52>: 02 46 mov r2, r0
0x08000a3e <Task_Start+54>: 0b 46 mov r3, r1
0x08000a40 <Task_Start+56>: 10 46 mov r0, r2
0x08000a42 <Task_Start+58>: 19 46 mov r1, r3
0x08000a44 <Task_Start+60>: 4f f0 00 02 mov.w r2, #0
0x08000a48 <Task_Start+64>: 13 4b ldr r3, [pc, #76] ; (0x8000a98 <Task_Start+144>)
0x08000a4a <Task_Start+66>: 13 f0 06 ef blx 0x8014858 <__divdf3>
0x08000a4e <Task_Start+70>: 02 46 mov r2, r0
0x08000a50 <Task_Start+72>: 0b 46 mov r3, r1
0x08000a52 <Task_Start+74>: 10 46 mov r0, r2
0x08000a54 <Task_Start+76>: 19 46 mov r1, r3
0x08000a56 <Task_Start+78>: 14 f0 a8 e8 blx 0x8014ba8 <__fixunsdfsi>
0x08000a5a <Task_Start+82>: 03 46 mov r3, r0
0x08000a5c <Task_Start+84>: bb 60 str r3, [r7, #8]
(gdb) ni
0x08000a38 81 16;
0x08000a36 <Task_Start+46>: f8 68 ldr r0, [r7, #12]
=> 0x08000a38 <Task_Start+48>: 13 f0 46 ed blx 0x80144c8 <__floatunsidf>
0x08000a3c <Task_Start+52>: 02 46 mov r2, r0
0x08000a3e <Task_Start+54>: 0b 46 mov r3, r1
0x08000a40 <Task_Start+56>: 10 46 mov r0, r2
0x08000a42 <Task_Start+58>: 19 46 mov r1, r3
0x08000a44 <Task_Start+60>: 4f f0 00 02 mov.w r2, #0
0x08000a48 <Task_Start+64>: 13 4b ldr r3, [pc, #76] ; (0x8000a98 <Task_Start+144>)
0x08000a4a <Task_Start+66>: 13 f0 06 ef blx 0x8014858 <__divdf3>
0x08000a4e <Task_Start+70>: 02 46 mov r2, r0
0x08000a50 <Task_Start+72>: 0b 46 mov r3, r1
0x08000a52 <Task_Start+74>: 10 46 mov r0, r2
0x08000a54 <Task_Start+76>: 19 46 mov r1, r3
0x08000a56 <Task_Start+78>: 14 f0 a8 e8 blx 0x8014ba8 <__fixunsdfsi>
0x08000a5a <Task_Start+82>: 03 46 mov r3, r0
0x08000a5c <Task_Start+84>: bb 60 str r3, [r7, #8]
(gdb) ni
HardFault_Handler () at stm32f10x_it.c:61
61 {
=> 0x080001f4 <HardFault_Handler+0>: 80 b4 push {r7}
0x080001f6 <HardFault_Handler+2>: 00 af add r7, sp, #0
(gdb)
执行了0x08000a38 <Task_Start+48>: 13 f0 46 ed blx 0x80144c8 <__floatunsidf>这条之后进入的硬中断,0x80144c8的最低位是0,明显是要切换到ARM状态,等待的只有硬中断,为什么会产生这类的非法指令?“
此帖出自
小平头技术问答
一周热门 更多>