File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,15 @@ rt_hw_interrupt_enable:
4949rt_hw_context_switch_to:
5050 la t0, __rt_rvstack
5151#ifdef SOC_RISCV_FAMILY_CH32
52+ /*
53+ * if it is an assembly entry code, the SP offset value is determined by the assembly code,
54+ * but the C code is determined by the compiler, so we subtract 512 here as a reservation.
55+ * When entering the interrupt function of C code, the compiler automatically presses the stack
56+ * into the task stack. We can only change the SP value used by the calling function after switching
57+ * the interrupt stack.This problem can be solved by modifying the interrupt to the assembly entry,
58+ * and there is no need to reserve 512 bytes. You only need to switch the interrupt stack at the
59+ * beginning of the interrupt function
60+ */
5261 addi t0, t0, -512 // for ch32
5362#endif /* SOC_RISCV_FAMILY_CH32 */
5463 csrw mscratch,t0
You can’t perform that action at this time.
0 commit comments