主程序如下所示:
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
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
主程序里就没有设置进入中断的语言。。。当然进步去了。。。
一周热门 更多>