经单步,发现在如下函数:(rvds.s文件中)
;/*
; * void rt_hw_context_switch_to(rt_uint32 to);
; * r0 --> to
; * this fucntion is used to perform the first thread switch
; */
rt_hw_context_switch_to PROC
EXPORT rt_hw_context_switch_to
; set to thread
LDR r1, =rt_interrupt_to_thread
STR r0, [r1]
; set from thread to 0
LDR r1, =rt_interrupt_from_thread
MOVS r0, #0x0
STR r0, [r1]
; set interrupt flag to 1
LDR r1, =rt_thread_switch_interrupt_flag
MOVS r0, #1
STR r0, [r1]
; set the PendSV exception priority
LDR r0, =NVIC_SHPR3
LDR r1, =NVIC_PENDSV_PRI
LDR r2, [r0,#0x00] ; read
ORRS r1,r1,r2 ; modify
STR r1, [r0] ; write-back
; trigger the PendSV exception (causes context switch)
LDR r0, =NVIC_INT_CTRL
LDR r1, =NVIC_PENDSVSET
STR r1, [r0]
; restore MSP
LDR r0, =SCB_VTOR
LDR r0, [r0]
LDR r0, [r0]
MSR msp, r0
; enable interrupts at processor level
CPSIE I ;faultful exception
; never reach here!
ENDP
CPSIE I 这个执行会导致出现问题 rt_hw_hard_fault_exception
用的rtthread 版本椒3.13,在keil上模拟仿真。
谢谢
代码没问题,是keil软件仿真的问题,全速跑应该能过。
还不行的话请使用硬件,不过这条指令也不能单步,因为单步时调试器自动关中断的。
另外,建议使用 stm32f103芯片来做软仿。
https://club.rt-thread.org/ask/question/427218.html