iiio051031448 发表于 2012-3-14 19:53:38

新手请教,中断老是跳入Abort模式,请高手指点

;有jlink全速运行就跳到 DataAbort 出不来 高手指点
        IMPORT Main
        IMPORT IRQ_Exception
       
        AREA |C$$code|, CODE, READONLY
        ENTRY
       
start
;interrupt vectors
;中断向量表
Reset
        LDR   PC, ResetAddr
    LDR   PC, ResetAddr
    LDR   PC, SWI_Addr
    LDR   PC, PrefetchAddr
    LDR   PC, DataAbortAddr
    DCD   0xb9205f80
    LDR   PC, IRQAddr
    LDR   PC, FIRQAddr
      
ResetAddr         DCD   ResetInit
UndefinedAddr       DCD   Undefined
SWI_Addr            DCD   SoftwareInterrupt
PrefetchAddr      DCD   PrefetchAbort
DataAbortAddr       DCD   DataAbort
                  DCD   0
IRQAddr             DCD   IRQHandler
FIRQAddr            DCD   FIRQHandler

;未定义指令
Undefined
                B       Undefined
;软中断
SoftwareInterrupt   
      B       SoftwareInterrupt
;取指令中止
PrefetchAbort
      B       PrefetchAbort
;取数据中止
DataAbort
      BDataAbort

;
IRQHandler
      STMFD SP!,{r0-r3,r12,lr}         ;保存现场
      ldr lr, =int_return                ;设置中断异常处理程序返回地址到下面的位置
      BIRQ_Exception                   ;直接进入到中断函数处理
int_return
      LDMFD SP!,{r0-r3,r12,lr}         ;恢复现场
      SUBS PC,LR,#4                      ;返回进入中断前的代码
                  
;
FIRQHandler
                STMFD sp!,{r0-r12,lr}   
                B      FIRQHandler
                LDMFD sp!, {r0-r12,lr}
                SUBSpc, lr,#4   

               
DISABLE_IRQ
                MRS R0, CPSR
                ORR R0, R0, #0x80
                MSR CPSR_c, R0
                MOV PC, LR                

;允许中断
ENABLE_IRQ
                MRS R0, CPSR         ;将CPSR保存至R0寄存器中
                BIC R0, R0, #0x80    ;R0 = R0 & ~0x80,清除中断位
                MSR CPSR_c, R0       ;将R0写回CPSR状态寄存器
                MOV PC, LR         ;返回到调用代码
ResetInit
                ldr r0,=0x7E004000
                ldr r1,=0x0000000
                str r1,
                LDR R14, =0x50100000 ;初始化一下栈指针
                BL       ENABLE_IRQ;打开中断允许位
                B       Main             ;跳入MAIN程序
ttS       
                LDR R5,=0xf0f0ff00
                mov pc,lr
        END
//========================================================

#define rGPMCON (*(volatile unsigned *)0x7F008820)
#define rGPMDAT (*(volatile unsigned *)0x7f008824)
#define rGPMPUD (*(volatile unsigned *)0x7f008828)

#define rGPFCON (*(volatile unsigned *)(0x7F0080A0))
#define rGPFDAT (*(volatile unsigned *)(0x7F0080A4))
#define rGPFPUD (*(volatile unsigned *)(0x7F0080A8))

#define rGPNCON (*(volatile unsigned *)(0x7F008830))
#define rGPNDAT (*(volatile unsigned *)(0x7F008834))
#define rGPNPUD (*(volatile unsigned *)(0x7F008838))

#define PCLK 66000000//for S3C6410 66MHZ
#define HCLK 133000000 //for S3C6410 133MHZ
#define rTCFG0 (*(volatile unsigned *)(0x7F006000))
#define rTCFG1 (*(volatile unsigned *)(0x7F006004))
#define rTCON (*(volatile unsigned *)(0x7F006008))
#define rTCNTB0 (*(volatile unsigned *)(0x7F00600C))
#define rTCMPB0 (*(volatile unsigned *)(0x7F006010))
#define rTCNTO0 (*(volatile unsigned *)(0x7F006014))
#define rTCNTB1 (*(volatile unsigned *)(0x7F006018))
#define rTCMPB1 (*(volatile unsigned *)(0x7F00601c))
#define rTCNTO1 (*(volatile unsigned *)(0x7F006020))
#define rTCNTB2 (*(volatile unsigned *)(0x7F006024))
#define rTCNTO2 (*(volatile unsigned *)(0x7F00602c))
#define rTCNTB3 (*(volatile unsigned *)(0x7F006030))
#define rTCNTO3 (*(volatile unsigned *)(0x7F006038))
#define rTCNTB4 (*(volatile unsigned *)(0x7F00603c))
#define rTCNTO4 (*(volatile unsigned *)(0x7F006040))
#define rTINT_CSTAT (*(volatile unsigned *)(0x7F006044))//定时器中断控制和状态寄存器

#define rVIC0INTENABLE (*(volatile unsigned *)(0x71200010))
#define rVIC1INTENABLE (*(volatile unsigned *)(0x71300010))

#define rVIC0VECTADDR((volatile unsigned *)(0x71200100))

void IRQ_Exception(void);

void GPIO_Init(void)
{
        // 初始化LED的IO配置
        rGPMCON = 0x11111;
        rGPMPUD = 0x0;
        rGPMDAT = 0x1F;
        // 初始化蜂鸣器IO配置
        rGPFCON = rGPFCON & (~(0x1 << (31)));
        rGPFCON = rGPFCON | (0x1 << (2*15));
        rGPFPUD = rGPFPUD & (~(0x3 << (2*15))) ;
        rGPFDAT = rGPFDAT & 0x7FFF;
}

void timer_init(void)
{
       rTINT_CSTAT |= 1<<0;   //开timer0中断,允许timer0中断发生
       rVIC0INTENABLE |= 1<<23;//开timer0的使能(相当于关掉mask)
       
       rTCFG0 &= ~0xFF;// 清除预分频因子位
       rTCFG0 |= 0x42;   // 设置分频因子(66分频), 定时器时钟频率为1Mhz
       rTCFG1 &= ~0x11;// 设置Divider MUX0为零 1分频
       
       rTCNTB0 = 0x100000;   //设初值(1s)
       
       rTCON |= 1<<1;      //开Manual Update (Update TCNTB0,TCMPB0)设置初值后要更新TCNTB
       rTCON |= 1<<3;      //Auto Reload on自动重装开启
       rTCON |= 1<<0;      //timer0 open;
       
       rTCON &= ~(1<<1);   //不再Update TCNTB0,TCMPB0
}

// 循环延时
void msDelay(int time)
{
        volatile unsigned int i, j;
        for(i = 0; i < 2000000; i++)
        {
                for (j = 0; j < time; j++);
        }
}

// 打开控件蜂鸣器的三极管
void BeepOff(void)
{
        rGPFDAT = rGPFDAT& 0x7fff;
}
// 关闭控件蜂鸣器的三极管
void BeepOn(void)
{
        rGPFDAT = rGPFDAT | 0x8000;
}

int i = 0;
// IRQ异常中断
void IRQ_Exception()
{
        rGPMDAT =~((0<<0)|(0<<1)|(0<<2)|(0<<3));
        i++;
        // 打开一个灯,并闭另外一个灯
        rGPMDAT = ~(1<<i++);
        BeepOn();
        msDelay(5);
        BeepOff();
               
        // 清除定时器中断状态位
        while((rTINT_CSTAT & 0x20)) rTINT_CSTAT |= (1 << 5);
}

void Main()
{
        rGPMDAT =~((1<<0)|(1<<1)|(1<<2)|(1<<3));
        GPIO_Init();
        timer_init();
        while(1);
}
页: [1]
查看完整版本: 新手请教,中断老是跳入Abort模式,请高手指点