嵌入式开发者社区

标题: SVC指令问题 [打印本页]

作者: zk_david    时间: 2019-4-9 08:41
标题: SVC指令问题
使用StarterWare裸机例程时,因重新初始化矢量表,使用soc库中,CopyVectorTable()重新定位异常中断矢量到OCRAM中,可以调用SVC指令,任然会调转到0xFFFF0008地址上,是什么地方没有配置好吗?

作者: 梁淑怡-Tronlong    时间: 2019-4-9 15:42
您好,
   请问您测试的是我司哪个案例?
作者: zk_david    时间: 2019-4-9 17:05
本帖最后由 zk_david 于 2019-4-9 17:10 编辑

移植freertos时遇到的,通过重新debug重新加载可以解决,怀疑使用调试器restart命令使内部配置出现异常,还不知道什么问题
作者: zk_david    时间: 2019-4-9 17:09
本帖最后由 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



[attach]4935[/attach]
[attach]4936[/attach]

作者: 梁淑怡-Tronlong    时间: 2019-4-10 14:15
您好,
          非常抱歉,由于我司未移植过FreeRTOS这个操作系统,因此难以复现您的问题进行排查,建议您可以搜索一下相关资料。





欢迎光临 嵌入式开发者社区 (https://51ele.net/) Powered by Discuz! X3.4