#define sortprio 3
#define IFX_INTPRIO_STM0_SR0 10
void handler_CPU0(void) //软件中断服务函数
{
IfxSrc_clearRequest(&SRC_GPSR_GPSR0_SR0); //清除标志位
IfxPort_togglePin(&MODULE_P33, 7);
}
void SW_int(void)
{
IfxPort_setPinMode(&MODULE_P33, 7, IfxPort_Mode_outputPushPullGeneral);
IFX_INTERRUPT(handler_CPU0, 0, sortprio); //注册中断
IfxSrc_init(&SRC_GPSR_GPSR0_SR0, IfxSrc_Tos_cpu0, sortprio ); //初始化软件中断
IfxSrc_enable(&SRC_GPSR_GPSR0_SR0); //使能
}
void soft_Trigger(void) //软件触发函数
{
INT_SRB0.B.TRIG0=1;
IfxPort_togglePin(&MODULE_P33, 1);
}
//main函数
int core0_main (void)
{
IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());
SW_int();
IfxCpu_enableInterrupts();
while(1)
{
IfxStm_waitTicks(&MODULE_STM0, 4000000);
IfxStm_waitTicks(&MODULE_STM0, 4000000);
IfxStm_waitTicks(&MODULE_STM0, 4000000);
IfxStm_waitTicks(&MODULE_STM0, 4000000);
soft_Trigger(); //间隔触发软件中断
}
return (1);
}
效果:流水灯间隔闪烁