Do let Stm32 trigger Svc interrupt and pass in parameters and then switch to handler mode and modify the value of the special register, so as to achieve the shutdown interrupt, but in fact this program is directly privileged level, so do not enter handler mode can also modify the special register ...
The following is a call to write the switch interrupt function:
Created a new file asm.c, all of the assembly functions I wrote are in:
The first two are off interrupts and open interrupt functions, the main thing to do is to pass parameters into the R8 and triggers the SVC interrupt.
A third set_i () function is called in the SVC interrupt.
When the interrupt is triggered, the M3 kernel enters handler mode, using the data in the R8 to modify the special register Basepri. This register can only be accessed at privileged levels.
Stm32 interrupts are grouped into group 1 with a priority number of 4, so a preemption priority of 1 interrupts is masked. Only the TIM3 interrupt preemption priority is 0, so only a tim3 interrupt can be performed after the first function is called.
From for notes (Wiz)
Write a Stm32 svc shutdown interrupt function