wangxiaorui 发表于 2012-8-16 14:32:19

ARM7TDMI 在IAR EWARM开发环境下,解决中断进不去问题

最近一直在做平台移植:ADS-->EWARM4.42(版本低哦{:smile:} ),在移植过程中遇到很多问题,最最头疼和郁闷的是中断进不去,查找了大量资料(只有问题没有说怎么解决,{:cry:} )和重复调试,最终终于解决了{:tongue:} 。为了大家节省时间,避免走弯路,下面跟大家分享一下哦。
稍等片刻哦~~~

wangxiaorui 发表于 2012-8-16 14:42:39

分析进不去中断原因:
首先,IAR EWARM有一个底层函数__low_lever_init(),会把总中断关闭:__disable_interrupt()关闭总中断,它是将CPSR的I位置位了。那么在您的主程序中,需要将总中断打开,即__enable_interrupt()。这两个函数都是在intrinsics.h中,可以在IAR帮助菜单找到哦。
其次,IAR需要cstarup.s文件,您配置好了,如果程序调试正常,添加了__enable_interrupt(),仍然只有中断进不去或者重复复位的时候,您就要注意了:中断向量地址是不是在cstarup.s文件中赋予了。如果没有,那是您的中断找不到中断入口。需要添加函数。下面是中断源初始化之后,挂两个中断源的程序,请大家多多指正哦!
嘻嘻

wangxiaorui 发表于 2012-8-16 14:46:49

wangxiaorui 发表于 2012-8-16 14:42 static/image/common/back.gif
分析进不去中断原因:
首先,IAR EWARM有一个底层函数__low_lever_init(),会把总中断关闭:__disable_inte ...

上程序了哦:
中断源处理:
__irq __arm void undefined_irq(void)
{
        AIC_IVR = 0; // Debug variant of vector read, protected mode is used.

// Do nothing.

        AIC_EOICR = 0; // Signal end of interrupt to AIC.
}


void AT91_InitInterrupt(void)
{
#if !ANGEL
        int      irq_id ;
#endif // ANGEL

#if !ANGEL
        // Disable all interrupts.
        AIC_IDCR = 0xFFFFFFFF;
        // Clear all interrupts.
        AIC_ICCR = 0xFFFFFFFF;

        // For each priority level.
        for (irq_id = 0; irq_id < 8; irq_id++)
        {
            // Unstack a level by writting in AIC_EOICR.
            // Value written has no effect.
            AIC_EOICR = 0;
        }

        {
            // For each interrupt source.
            __REG32 volatile* aic_smr_base = &__AIC_SMR0;
            __REG32 volatile* aic_svr_base = &__AIC_SVR0;
            for (irq_id = 0; irq_id < 32; irq_id++)
            {
                      // Priority is lowest.
                      aic_smr_base = 0 ;
                      // Interrupt routine is undefined.
                      aic_svr_base = (unsigned long)&undefined_irq;
            }
        }

        __AIC_SPU = (unsigned long)&undefined_irq; // Spurious interrupt vector.
        __SF_PMR = 0x27a80020; // Run AIC in protected mode.
        __SF_PMR = 0x27a80020; // Run AIC in protected mode. EB40A requires this twice.
        // Initialize ARM IRQ vector to map to interrupt controller.
        *(unsigned long *)0x18 = 0xe51fff20; // ldr pc,
#endif // ANGEL

#if ANGEL
        // The Angel ROM monitor code is written to allow AIC
        // protected mode. That means that from tis point it is
        // safe to look at the AIC registers from the memory and
        // register windows. Take care not to start up C-SPY with
        // AIC display active since the ROM monitor itself does not
        // Enable protected mode.
        __SF_PMR = 0x27a80020; // Run AIC in protected mode.
#endif // ANGEL
}

接着您就在AT91_InitInterrupt()函数后面配置您需要的中断即可,多少都可以,但是优先级您一定要设置好了。
接下来您的程序是不是可以进中断啦?{:handshake:}

haizheng4 发表于 2012-8-16 15:22:03

感谢分享 {:handshake:}

wangxiaorui 发表于 2012-8-17 09:16:25

haizheng4 发表于 2012-8-16 15:22 static/image/common/back.gif
感谢分享

{:smile:}

BILLCHIA 发表于 2012-8-19 20:17:48

mark!!!!!

fiaanull 发表于 2013-10-25 10:57:53

感谢分享!{:lol:}
页: [1]
查看完整版本: ARM7TDMI 在IAR EWARM开发环境下,解决中断进不去问题