小弟最近在44b0上移植ucos,出现了一个问题,在调试时候,当运行OSTimeDly时出现这样一个错误,请教高手解决
Processor ARM7TDMI raised an exception
cause: Undefined Instruction
OS_CPU_A.a如下
AREA |TEST|, CODE, READONLY
EXPORT OSStartHighRdy
IMPORT OSRunning
IMPORT OSTaskSwHook
IMPORT OSTCBHighRdy
OSStartHighRdy
BL OSTaskSwHook ;Call user defined Hook function
LDR R4, =OSRunning ;Set OSRunning to 1
MOV R5, #1
STRB R5, [R4]
LDR r4,=OSTCBCur
LDR r5,=OSTCBHighRdy
LDR r5,=OSTCBHighRdy
LDR r5,[r5]
LDR sp,[r5]
STR r5,[r4]
LDMFD sp!,{r4}
MSR CPSR_cxsf,r4
LDMFD sp!,{r0-r12,lr,pc}
EXPORT OSCtxSw
IMPORT OSTCBCur
IMPORT OSTaskSwHook
IMPORT OSTCBHighRdy
IMPORT OSPrioCur
IMPORT OSPrioHighRdy
OSCtxSw
STMFD sp!,{lr}
STMFD sp!,{lr}
STMFD sp!,{r0-r12}
MRS r4,CPSR
STMFD sp!,{r4}
MRS r4,SPSR
STMFD sp!,{r4}
LDR r4,=OSPrioCur
LDR r5,=OSPrioHighRdy
LDRB r6,[r5]
STRB r6,[r4]
LDR r4,=OSTCBCur
LDR r5,[r4]
STR sp,[r5]
LDR r6,=OSTCBHighRdy
LDR r6,[r6]
LDR sp,[r6]
STR r6,[r4]
LDMFD sp!,{r4}
MSR SPSR_cxsf,r4
LDMFD sp!,{r4}
MSR SPSR_cxsf,r4
LDMFD sp!, {R0-R12,LR,PC}
EXPORT OSIntCtxSw
IMPORT OSTaskSwHook
IMPORT OSTCBCur
IMPORT OSTCBHighRdy
IMPORT OSPrioCur
IMPORT OSPrioHighRdy
OSIntCtxSw
BL OSTaskSwHook ;Recall usr defined OSTaskSwHook()
LDR R4, =OSTCBHighRdy ;OSTCBCur = OSTCBHighRdy;
LDR R4, [R4]
LDR R5, =OSTCBCur
STR R4, [R5]
LDR R4, =OSPrioHighRdy ;OSPrioCur = OSPrioHighRdy;
LDR R4, [R4]
LDR R5, =OSPrioCur
STRB R4, [R5]
LDR R4, =OSTCBHighRdy ;Stack pointer = OSTCBHighRdy->OSTCBStkPtr;
LDR R4, [R4]
LDR sp, [R4]
LDMFD sp!, {R4} ;resume all processors registers from the new task
MSR cpsr_cxsf, R4
LDMFD sp!, {R0-R12,LR,PC}
EXPORT OSTickISR
IMPORT OSTCBCur
IMPORT OSIntNesting
IMPORT OSTimeTick
IMPORT OSIntExit
OSTickISR
STMFD sp!, {LR} ;Save mcu registers
STMFD sp!, {R0-R12,LR}
MRS R4, cpsr
STMFD sp!, {R4}
LDR R4, =OSIntNesting ;OSIntNesting +1
LDR R4, [R4]
ADD R4, R4, #1
CMP R4, #1 ;if (OSIntNesting == 1){
BNE JMP
LDR R4, =OSTCBCur ;OSTCBCur->OSTCBStkPtr = Stack Pointer;}
LDR R4, [R4]
STR sp, [R4]
JMP
BL OSTimeTick ;OSTimeTick();
BL OSIntExit ;OSIntExit();
LDMFD sp!, {R4} ;resume processors registers
MSR cpsr_cxsf, R4
LDMFD sp!, {R0-R12,LR,PC}
EXPORT ARMDisableInt
ARMDisableInt
MRS R0, cpsr
MOV R1,R0
; STMFD sp!, {R0} ; push current PSR
ORR R1, R1, #0xC0
MSR cpsr_cxsf, R1 ; disable IRQ Int s
MOV PC, LR
EXPORT ARMEnableInt
ARMEnableInt
;LDMFD sp!, {R0} ; pop current PSR
;MSR cpsr_c, R0 ; restore original cpsr
MRS R0,CPSR
bic r0,r0,#0xC0
msr cpsr_cxsf,r0
MOV PC, LR
END
主函数如下
#include "includes.h"
#define TASK_STK_SIZE 512
OS_STK TASKONESTK[TASK_STK_SIZE];
OS_STK TASKTWOSTK[TASK_STK_SIZE];
OS_STK STARTSTK[TASK_STK_SIZE];
void start(void *data);
void TaskOne(void *data);
void TASKTWO(void *data);
/****************************************/
void start(void *data)
{
data=data;
OSTaskCreate(TaskOne,(void *)0,&TASKONESTK[TASK_STK_SIZE-1],5);
OSTaskCreate(TASKTWO,(void *)0,&TASKTWOSTK[TASK_STK_SIZE-1],6);
while(1)
{
OSTimeDly(200);
}
}
void TaskOne(void *data)
{
data=data;
while(1)
{
Uart_Printf("\n4555\n");
OSTimeDly(2);
}
}
void TASKTWO(void *data)
{
data=data;
while(1)
{
Uart_Printf("\njljkjjk\n");
OSTimeDly(2);
}
}
void Main(void)
{
rSYSCFG=0x0e;//写8KB缓冲使能,数据异常结束有效,延迟无效.
ChangePllValue(120,8,2);//设置锁相环参数,使晶振频率转化为用户需要的频率.
Port_Init(); //IO端口功能、方向设定
Uart_Init(0,115200);//串口初始化
Uart_Select(0);
OSInit();
OSTaskCreate(start,(void *)0,&STARTSTK[TASK_STK_SIZE-1],3);
OSStart();
}