ARM PWM中断无法进入
时间:10-02
整理:3721RD
点击:
主程序如下所示:
int main(void)
{
PINSEL0 = 0x000A800A;
PINSEL1 = 0x00000400;
PWMPR = 0x00;
PWMMCR = 0x03;
PWMMR0 = Fpclk/50;
PWMPCR = 0x7e54;
PWMTCR = 0x09;
i=!i;
while(1);
return(0);
}
中断程序如下所示:
void Interrupt_Init()
{
VICIntSelect = 0x00000000;
VICVectCntl8 = 0x00000028;
VICVectAddr8 = (uint32)IRQ_PWM;
VICIntEnable = 1 << 8;
}
void __irq IRQ_PWM (void)
{
switch(flag)
{
case 0:
PWMMR1 = Fpclk/200;
PWMMR2 = Fpclk/100;
PWMLER = 0x7f;
break;
case 1:
PWMMR1 = Fpclk/200;
PWMMR2 = Fpclk/50;
PWMLER = 0x7f;
break;
}
PWMIR = 0x01;
VICVectAddr = 0x00;
}
PS:我已经把StartupS中的系统模式堆栈设置为: MSR CPSR_c, #0x5f
LDR SP, =StackUsr
MOV PC, R0
int main(void)
{
PINSEL0 = 0x000A800A;
PINSEL1 = 0x00000400;
PWMPR = 0x00;
PWMMCR = 0x03;
PWMMR0 = Fpclk/50;
PWMPCR = 0x7e54;
PWMTCR = 0x09;
i=!i;
while(1);
return(0);
}
中断程序如下所示:
void Interrupt_Init()
{
VICIntSelect = 0x00000000;
VICVectCntl8 = 0x00000028;
VICVectAddr8 = (uint32)IRQ_PWM;
VICIntEnable = 1 << 8;
}
void __irq IRQ_PWM (void)
{
switch(flag)
{
case 0:
PWMMR1 = Fpclk/200;
PWMMR2 = Fpclk/100;
PWMLER = 0x7f;
break;
case 1:
PWMMR1 = Fpclk/200;
PWMMR2 = Fpclk/50;
PWMLER = 0x7f;
break;
}
PWMIR = 0x01;
VICVectAddr = 0x00;
}
PS:我已经把StartupS中的系统模式堆栈设置为: MSR CPSR_c, #0x5f
LDR SP, =StackUsr
MOV PC, R0
自己搞定了,是什么原因没进中断?
主程序里就没有设置进入中断的语言。当然进步去了。
来学习学习!