caosui1207 发表于 2009-7-21 09:15:55

ucos-ii在IAR5.4下编译通不过

刚装了IAR5.4 EV版,在编译ucos-ii的os_cpu_a.asm文件时出错:Error: Branch to unaligned address E:\irobot\uCOS-II\Ports\ARM-Cortex-M3\Generic\IAR\os_cpu_a.asm 201 Error while running Assembler 。用5.3时并没有这个问题啊

chrainbow 发表于 2009-8-15 21:50:11

回复:ucos-ii在IAR5.4下编译通不过

不知楼主的问题解决了没有,我这有个方法,请楼主试试。
我试了是可以的。
这个问题只是在IAR ARM5.4中才有,5.2的就没有。

OS_CPU_PendSVHandler
    CPSID   I                                                   ; Prevent interruption during context switch
    MRS     R0, PSP                                             ; PSP is process stack pointer
    CBZ     R0, OS_CPU_PendSVHandler_nosave                     ; Skip register save the first time

    SUBS    R0, R0, #0x20                                       ; Save remaining regs r4-11 on process stack
    STM     R0, {R4-R11}

    LDR     R1, =OSTCBCur                                       ; OSTCBCur->OSTCBStkPtr = SP;
    LDR     R1,
    STR     R0,                                             ; R0 is SP of process being switched out

    ;加入下面的这个"THUMB"就可以了
    THUMB
                                                                ; At this point, entire context of process has been saved
OS_CPU_PendSVHandler_nosave
    PUSH    {R14}                                               ; Save LR exc_return value
    LDR     R0, =OSTaskSwHook                                   ; OSTaskSwHook();
    BLX     R0
    POP     {R14}

    LDR     R0, =OSPrioCur                                      ; OSPrioCur = OSPrioHighRdy;
    LDR     R1, =OSPrioHighRdy
    LDRB    R2,
    STRB    R2,

    LDR     R0, =OSTCBCur                                       ; OSTCBCur  = OSTCBHighRdy;
    LDR     R1, =OSTCBHighRdy
    LDR     R2,
    STR     R2,

    LDR     R0,                                             ; R0 is new process SP; SP = OSTCBHighRdy->OSTCBStkPtr;
    LDM     R0, {R4-R11}                                        ; Restore r4-11 from new process stack
    ADDS    R0, R0, #0x20
    MSR     PSP, R0                                             ; Load PSP with new process SP
    ORR     LR, LR, #0x04                                       ; Ensure exception return uses process stack
    CPSIE   I
    BX      LR                                                  ; Exception return will restore remaining context

    END

gideon518j 发表于 2009-8-18 17:35:35

RE:ucos-ii在IAR5.4下编译通不过

Cortex M3都是Thumb指令, 跳转地址bit应为1
页: [1]
查看完整版本: ucos-ii在IAR5.4下编译通不过