21ic问答首页 - nuclei gd32vf103向量中断示例代码疑问
nuclei gd32vf103向量中断示例代码疑问
lindahnu2024-05-06
使用Nuclei Studio生成eclic中断示例代码,timer实现非向量中断和向量中断,其中eclic_msip_handler函数实现调用了 SAVE_IRQ_CSR_CONTEXT()和RESTORE_IRQ_CSR_CONTEXT();看实现代码发现,RESTORE_IRQ_CSR_CONTEXT()是关闭了全局中断,那下次中断还怎么响应呢?eclic_msip_handler就只执行了一次,在main函数里还判断了这个函数的执行次数,不明白,求解答。
__INTERRUPT void eclic_msip_handler(void)
{
static uint32_t int_sw_cnt = 0; /* software interrupt counter */
// save CSR context
SAVE_IRQ_CSR_CONTEXT();
SysTimer_ClearSWIRQ();
...
int_check_cnt ++;
// restore CSR context
RESTORE_IRQ_CSR_CONTEXT();
}
int main(int argc, char** argv)
{
................
while (int_check_cnt < RUN_LOOPS);
__disable_irq();
printf("ECLIC Demo finished sucessfully in %d loops\n", RUN_LOOPS);
return 0;
}
#define SAVE_IRQ_CSR_CONTEXT() \
rv_csr_t __mcause = __RV_CSR_READ(CSR_MCAUSE);\
rv_csr_t __mepc = __RV_CSR_READ(CSR_MEPC); \
rv_csr_t __msubm = __RV_CSR_READ(CSR_MSUBM);\
__enable_irq();
#define RESTORE_IRQ_CSR_CONTEXT() \
__disable_irq(); \
__RV_CSR_WRITE(CSR_MSUBM, __msubm);
__RV_CSR_WRITE(CSR_MEPC, __mepc);
__RV_CSR_WRITE(CSR_MCAUSE, __mcause);
__INTERRUPT void eclic_msip_handler(void)
{
static uint32_t int_sw_cnt = 0; /* software interrupt counter */
// save CSR context
SAVE_IRQ_CSR_CONTEXT();
SysTimer_ClearSWIRQ();
...
int_check_cnt ++;
// restore CSR context
RESTORE_IRQ_CSR_CONTEXT();
}
int main(int argc, char** argv)
{
................
while (int_check_cnt < RUN_LOOPS);
__disable_irq();
printf("ECLIC Demo finished sucessfully in %d loops\n", RUN_LOOPS);
return 0;
}
#define SAVE_IRQ_CSR_CONTEXT() \
rv_csr_t __mcause = __RV_CSR_READ(CSR_MCAUSE);\
rv_csr_t __mepc = __RV_CSR_READ(CSR_MEPC); \
rv_csr_t __msubm = __RV_CSR_READ(CSR_MSUBM);\
__enable_irq();
#define RESTORE_IRQ_CSR_CONTEXT() \
__disable_irq(); \
__RV_CSR_WRITE(CSR_MSUBM, __msubm);
__RV_CSR_WRITE(CSR_MEPC, __mepc);
__RV_CSR_WRITE(CSR_MCAUSE, __mcause);
您需要登录后才可以回复 登录 | 注册