| 
 | 
地板
 
 
 楼主 |
发表于 2019-4-9 17:09:11
|
只看该作者
 
 
 
 本帖最后由 zk_david 于 2019-4-9 17:27 编辑  
 
配置timer2溢出中断,ack ID 1023产生中断,是什么问题? 
.align 4 
.type IRQ_Handler, %function 
IRQ_Handler: 
        /* Return to the interrupted instruction. */ 
        SUB                lr, lr, #4 
 
        /* Push the return address and SPSR. */ 
        PUSH        {lr} 
        MRS                lr, SPSR 
        PUSH        {lr} 
 
        /* Change to supervisor mode to allow reentry. */ 
        CPS                #SVC_MODE 
 
        /* Push used registers. */ 
        PUSH        {r0-r4, r12} 
 
        /* Increment nesting count.  r3 holds the address of ulPortInterruptNesting 
        for future use.  r1 holds the original ulPortInterruptNesting value for 
        future use. */ 
        LDR                r3, ulPortInterruptNestingConst 
        LDR                r1, [r3] 
        ADD                r4, r1, #1 
        STR                r4, [r3] 
 
        /* Read value from the interrupt acknowledge register, which is stored in r0 
        for future parameter and interrupt clearing use. */ 
        LDR         r2, ulICCIARConst 
        LDR                r2, [r2] 
        LDR                r0, [r2] 
 
        /* Ensure bit 2 of the stack pointer is clear.  r2 holds the bit 2 value for 
        future use.  _RB_ Does this ever actually need to be done provided the start 
        of the stack is 8-byte aligned? */ 
        MOV                r2, sp 
        AND                r2, r2, #4 
        SUB                sp, sp, r2 
 
        /* Call the interrupt handler.  r4 pushed to maintain alignment. */ 
        PUSH        {r0-r4, lr} 
        LDR                r1, vApplicationIRQHandlerConst 
        BLX                r1 
        POP                {r0-r4, lr} 
        ADD                sp, sp, r2 
 
        CPSID        i 
        DSB 
        ISB 
 
        /* Write the value read from ICCIAR to ICCEOIR. */ 
        LDR         r4, ulICCEOIRConst 
        LDR                r4, [r4] 
        STR                r0, [r4] 
 
        /* Restore the old nesting count. */ 
        STR                r1, [r3] 
 
        /* A context switch is never performed if the nesting count is not 0. */ 
        CMP                r1, #0 
        BNE                exit_without_switch 
 
        /* Did the interrupt request a context switch?  r1 holds the address of 
        ulPortYieldRequired and r0 the value of ulPortYieldRequired for future 
        use. */ 
        LDR                r1, =ulPortYieldRequired 
        LDR                r0, [r1] 
        CMP                r0, #0 
        BNE                switch_before_exit 
 
exit_without_switch: 
        /* No context switch.  Restore used registers, LR_irq and SPSR before 
        returning. */ 
        POP                {r0-r4, r12} 
        CPS                #IRQ_MODE 
        POP                {LR}/*执行到这一步的时候,lr值就不对,*/ 
        MSR                SPSR_cxsf, LR 
        POP                {LR} 
        MOVS        PC, LR 
         switch_before_exit: 
        /* A context swtich is to be performed.  Clear the context switch pending 
        flag. */ 
        MOV                r0, #0 
        STR                r0, [r1] 
 
        /* Restore used registers, LR-irq and SPSR before saving the context 
        to the task stack. */ 
        POP                {r0-r4, r12} 
        CPS                #IRQ_MODE 
        POP                {LR} 
        MSR                SPSR_cxsf, LR 
        POP                {LR} 
        portSAVE_CONTEXT 
 
        /* Call the function that selects the new task to execute. 
        vTaskSwitchContext() if vTaskSwitchContext() uses LDRD or STRD 
        instructions, or 8 byte aligned stack allocated data.  LR does not need 
        saving as a new LR will be loaded by portRESTORE_CONTEXT anyway. */ 
        LDR                R0, vTaskSwitchContextConst 
        BLX                R0 
 
        /* Restore the context of, and branch to, the task selected to execute 
        next. */ 
        portRESTORE_CONTEXT 
 
 
 
 
 
 |   
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册 
 
 
 
x
 
 
 
 
 |