所有的DSC都是标量中断,即每一个中断源都对应一个固定的中断矢量。 首先设定中断的条件:
1)设定中断源的优先级:*((unsigned int *)INTC_IPRx)|=0x00C0;
2)中断源中断Enable, 举个PWM的例子:*((unsigned int *)PWM_SM0INTEN)|=0x1000;
3)写中断函数:
#pragma interrupt on
void PWM_RELOAD_ISR()
{
//clear the RF flag in PWM_SM0STS
*((unsigned int *)PWM_SM0STS)|=0x1000; //writting 1 to clear the RF bit
if(changeFlag)
{
*((unsigned int *)PWM_SM1VAL2)=0xFA00; //75% duty cycle
*((unsigned int *)PWM_SM1VAL3)=0x400;
*((unsigned int *)PWM_SM1VAL4)=0xFA00; //75% duty cycle
*((unsigned int *)PWM_SM1VAL5)=0x400;
。。。
}
4)修改中断矢量表in vector.c:
jsr >FPWM_RELOAD_ISR ;MC56F824x_5x_ISR_PWM_RELOAD0 ;submodule 0 reload interrupt 0-2 0x68 52
5)开中断
asm(bfclr #$0300,sr);