Hi All,
I'm experiencing a strange problem where my code would get stuck in os_tmr_call() in the rtx_config.c. My variable OS_TIMERCNT is set to 0 (default) so I'm not using it. The value of the "info" argument passed in is 0. To shed more light to the problem, when the firmware is just running idling then I don't experience this problem. As soon as I start UART send and receive, my code would get stuck in os_tmr_call() after a few seconds.
I'm posting my rtx_config.c for reference and I would appreciate any help or suggestions.
Thanks, Shane
#ifndef OS_TASKCNT #define OS_TASKCNT 4 #endif #define OS_PRIVCNT 3 #endif #ifndef OS_STKSIZE #define OS_STKSIZE 50 #endif #ifndef OS_STKCHECK #define OS_STKCHECK 1 #endif #ifndef OS_TIMER #define OS_TIMER 0 #endif #ifndef OS_CLOCK #define OS_CLOCK 1409024 #endif #ifndef OS_TICK #define OS_TICK 10000 #endif #ifndef OS_ROBIN #define OS_ROBIN 1 #endif #ifndef OS_ROBINTOUT #define OS_ROBINTOUT 5 #endif #ifndef OS_TIMERCNT #define OS_TIMERCNT 0 #endif #ifndef OS_FIFOSZ #define OS_FIFOSZ 16 #endif #ifndef OS_MUTEXCNT #define OS_MUTEXCNT 8 #endif /*---------------------------------------------------------------------------- * RTX User configuration part END *---------------------------------------------------------------------------*/ #if (OS_TIMER == 0) /* Timer 0 (RTOS) */ #define OS_TID_ 2 /* Timer ID */ #define OS_TIM_ (1 << OS_TID_) /* Interrupt Mask */ #define OS_TRV ((U16)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1) #define OS_TVAL (OS_TRV - T0VAL) /* Timer Value */ #define OS_TOVF (IRQSIG & OS_TIM_) /* Overflow Flag */ #define OS_TFIRQ() if (IRQEN & OS_TIM_) SWICFG |= 2;/* Force Interrupt */ \ else force_irq = __TRUE; #define OS_TIACK() SWICFG &= ~2; /* Interrupt Ack */ \ T0CLRI = 1; \ force_irq = __FALSE; #define OS_TINIT() T0LD = OS_TRV; /* Initialization */ \ T0CON = 0xC4; #else #error OS_TIMER invalid #endif #define OS_IACK() ; /* Interrupt Ack */ #define OS_LOCK() IRQCLR = OS_TIM_; /* Task Lock */ #define OS_UNLOCK() IRQEN |= OS_TIM_; /* Task Unlock */ \ if (force_irq) SWICFG |= 2; /* WARNING: Using IDLE mode might cause you troubles while debugging. */ #define _idle_() ; static BIT force_irq; /*---------------------------------------------------------------------------- * Global Functions *---------------------------------------------------------------------------*/ extern void os_clock_interrupt (void); void os_def_interrupt (void) __irq; /*--------------------------- IRQ_Handler -----------------------------------*/ // User Interrupt Functions //extern __irq void IRQx (void); // User IRQx Function extern __irq void IRQ_Uart (void); //#define mIRQx 0x00000080 // User IRQx Mask #define mIRQ_Uart 0x00004000 // UART Mask for Aduc702x __asm void IRQ_Handler (void) { // Common IRQ Handler PRESERVE8 ARM STMDB SP!,{R0} ; Save R0 LDR R0,=__cpp((U32)&IRQSTA) ; Load IRQSTA Address LDR R0,[R0] ; Load IRQSTA Value // TST R0,#mIRQx ; Check IRQx Flag // LDMNEIA SP!,{R0} ; Restore R0 // LDRNE PC,=__cpp(IRQx) ; IRQx Function TST R0,#mIRQ_Uart ; Check UART big LDMNEIA SP!,{R0} ; Restore R0 LDRNE PC,=__cpp(IRQ_Uart) ; IRQ_Uart Function TST R0,#(SWI_BIT :OR: RTOS_TIMER_BIT) ; Check OS IRQ Flag LDMIA SP!,{R0} ; Restore R0 LDRNE PC,=__cpp(os_clock_interrupt) ; OS Clock IRQ Function LDR PC,=__cpp(os_def_interrupt) ; OS Default IRQ Function } /*--------------------------- os_idle_demon ---------------------------------*/ __task void os_idle_demon (void) { /* The idle demon is a system task, running when no other task is ready */ /* to run. The 'os_xxx' function calls are not allowed from this task. */ for (;;) { /* HERE: include optional user code to be executed when no task runs.*/ } } /*--------------------------- os_tmr_call -----------------------------------*/ void os_tmr_call (U16 info) { /* This function is called when the user timer has expired. Parameter */ /* 'info' holds the value, defined when the timer was created. */ /* HERE: include optional user code to be executed on timeout. */ } /*--------------------------- os_error --------------------------------------*/ void os_error (U32 err_code) { /* This function is called when a runtime error is detected. Parameter */ /* 'err_code' holds the runtime error code (defined in RTL.H). */ /* HERE: include optional code to be executed on runtime error. */ for (;;); } void os_def_interrupt (void) __irq { /* Default Interrupt Function: may be called when timer ISR is disabled */ OS_IACK(); } #include <RTX_lib.c>