发新话题
打印

求教UCOSII在44B0上的问题

求教UCOSII在44B0上的问题

UCOSII移植到44B0上,还比较顺利,有现成的代码


现在在调试2个中断,一个是TIMER0的节拍中断,一个是TIMER3的中断


结果出现问题,当两个中断一起跑的时候,运行一段时间就卡死了,可能是出现了异常中断


屏蔽掉任何一个中断的时候都跑的很好


高手们,来指点下~~


这是汇编上的TIMER3的中断子程序


BIT_TIMER0 EQU (0x1<<13)
BIT_GLOBAL EQU (0x1<<26)
I_ISPC EQU 0x1e00024
INTMSK EQU 0x1e0000c
BIT_TIMER3 EQU (0x1<<10);



AREA |C$$code|, CODE, READONLY

IMPORT need_to_swap_context
IMPORT Timer3Int
IMPORT IrqStart
IMPORT IrqFinish
IMPORT _CON_SW
IMPORT _NOT_CON_SW

EXPORT Timer3_ISR

Timer3_ISR
STMDB sp!,{r0-r11,lr} ;=push lr, r0-r11-->sp


;interrupt disable(not nessary)
mrs r0, CPSR ; r0=CPSR
orr r0, r0, #0x80 ; and set IRQ disable flag
msr CPSR_cxsf, R0 ; CPSR_cxsf=R0

;End of interrupt
;(Clear pending bit of INTPEND that don't accessed it.)
;rI_ISPC= BIT_TIMER3;


LDR r0, =I_ISPC
LDR r1, =BIT_TIMER3
STR r1, [r0]

LDR R0, =INTMSK
LDR R2, [R0]
LDR R1, =BIT_TIMER3
ORR R2, R1, R2
LDR R1, =BIT_TIMER0
ORR R2, R1, R2
STR R2, [R0]


BL IrqStart

BL Timer3Int


BL IrqFinish

LDR r0, =need_to_swap_context
LDR r2, [r0] ;ldr: memory to register,r2=need_to_swap_context
CMP r2, #1
LDREQ pc, =_CON_SW;if equal,then switch context
LDR pc, =_NOT_CON_SW

END



这是主程序


#include "bsp\cpu\def.h"
#include "bsp\uart\uart.h"
#include "bsp\cpu\44blib.h"
#include "bspinit.h"
#include "bsp\cpu\44breg.h"
#include "ucos-ii\includes.h"


int isrtxmsg=1;
int n=0;
OS_EVENT *ISRTaskMbox;


extern void Timer3_ISR(void);


#ifdef SEMIHOSTED
#define STACKSIZE (64+SEMIHOSTED_STACK_NEEDS)
#else
#define STACKSIZE 256
#endif


OS_STK Main_Stack[STACKSIZE]={0,};
void Main_Task(void *ld);
#define Main_PRIO 10


OS_STK Task1_Stack[STACKSIZE]={0,};
void Task1_Task(void *ld);
#define Task1_PRIO 12


OS_STK Task2_Stack[STACKSIZE]={0,};
void Task2_Task(void *ld);
#define Task2_PRIO 14


OS_STK Task3_Stack[STACKSIZE]={0,};
void Task3_Task(void *ld);
#define Task3_PRIO 16


void Task1_Task(void *ld)
{
while(1)
{
OS_ENTER_CRITICAL();
Uart_Printf("1");
OS_EXIT_CRITICAL();
OSTimeDly(500);
}
}


void Task2_Task(void *ld)
{
while(1)
{
OS_ENTER_CRITICAL();
Uart_Printf("2");
OS_EXIT_CRITICAL();
OSTimeDly(500);
}
}


void Task3_Task(void *ld)
{
while(1)
{
OS_ENTER_CRITICAL();
Uart_Printf("3");
OS_EXIT_CRITICAL();
OSTimeDly(500);
}
}


void Timer3Int(void)
{
isrtxmsg=1;
OSMboxPost(ISRTaskMbox,(void *)&isrtxmsg);
Uart_Printf("!");
}


void _Delay(void)
{
int j,k;
for(j=0;j<255;j++)
{
for(k=0;k<255;k++);
}
}


void Main_Task(void *ld)
{
unsigned char err;
int *rxmsg=0;

ARMTargetStart();
rINTMOD=0x0;
rINTCON=0x5;
rINTMSK&=~(BIT_TIMER3);
pISR_TIMER3=(int)Timer3_ISR;
rTCFG0=(0xf<<8)+(0x4);
rTCFG1=(0x04<<12)+(0x3);
rTCNTB3=0xfff;
rTCON=(0x2<<16)+(0x2);
rTCON=(0x9<<16)+(0x9);
ISRTaskMbox=OSMboxCreate((void *)0);
OSTaskCreate(Task1_Task, (void *) 0, (OS_STK *)&Task1_Stack[STACKSIZE-1], Task1_PRIO);
OSTaskCreate(Task2_Task, (void *) 0, (OS_STK *)&Task2_Stack[STACKSIZE-1], Task2_PRIO);
OSTaskCreate(Task3_Task, (void *) 0, (OS_STK *)&Task3_Stack[STACKSIZE-1], Task3_PRIO);
while(1)
{
rxmsg=(int *)OSMboxPend(ISRTaskMbox,0,&err);
if(*rxmsg==1)
{
rINTMSK&=~(BIT_TIMER0);
rINTMSK|=BIT_TIMER3;
OS_ENTER_CRITICAL();
uHALr_printf("%d\n\r",n++);
OS_EXIT_CRITICAL();
rI_ISPC|=BIT_TIMER3;
rINTMSK&=~(BIT_TIMER3);
*rxmsg=0;
}
//OSTimeDly(500);
}
}


int Main(void)
{
Bsp_Init();
ARMTargetInit();
OSInit();
OSTaskCreate(Main_Task,(void *)0,(OS_STK *)&Main_Stack[STACKSIZE-1],Main_PRIO);
OSStart();
return 0;
}
/**************************

TOP

没有人在??

TOP

高手出来冒泡~~~

TOP

困扰了好久了,知道的说个话啊

TOP

发新话题