main.c加入如下代码用于触发PendSV中断异常。#define NVIC_INT_CTRL 0xE000Ed04 //PendSV中断控制器地址
#define NVIC_PENDSV_SET 0x10000000 //PendSV触发的值
#define NVIC_SYSPRI2 0xE000Ed22 //PendSV优先级控制地址
#define NVIC_PENDSV_PRI 0x000000ff //PendSV设置为最低优先值
#define MEM32(addr) *(volatile unsigned long *)(addr)
#define MEM8(addr) *(volatile unsigned char *)(addr)
// 触发PendSV中断异常
void trigger_PendSV(void)
{
MEM32(NVIC_INT_CTRL) = NVIC_PENDSV_SET; //触发PendSV
MEM8(NVIC_SYSPRI2) = NVIC_PENDSV_PRI; //设置PendSV优先级
}
|