This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC2368 - FreeRTOS Timer0 ever goes into Irq rutine

Hi,
I'm trying to start FreeRTOS on LPC2368. I'm using MCB2360, Keil uVision 4 Lite, Ulink-Me.
I haven't found a bug after hours of looking for errors and googling, so now i'm asking You for help.
Here's my src code:
Interrupt configuration:

/* Constants required to setup the tick ISR. */
#define portENABLE_TIMER                ( ( unsigned portCHAR ) 0x01 )
#define portPRESCALE_VALUE              0x00
#define portINTERRUPT_ON_MATCH          ( ( unsigned portLONG ) 0x01 )
#define portRESET_COUNT_ON_MATCH        ( ( unsigned portLONG ) 0x02 )

/* Constants required to setup the VIC for the tick ISR. */
#define portTIMER_VIC_CHANNEL           ( ( unsigned portLONG ) 0x0004 )
#define portTIMER_VIC_CHANNEL_BIT       ( ( unsigned portLONG ) 0x0010 )
#define portTIMER_VIC_ENABLE            ( ( unsigned portLONG ) 0x0020 )

static void prvSetupTimerInterrupt( void )
{
unsigned portLONG ulCompareMatch;

        PCLKSEL0 = (PCLKSEL0 & (~(0x3<<2))) | (0x01 << 2);
        T0TCR  = 2;         /* Stop and reset the timer */
        T0CTCR = 0;         /* Timer mode               */

        /* A 1ms tick does not require the use of the timer prescale.  This is
        defaulted to zero but can be used if necessary. */
        T0PR = portPRESCALE_VALUE;

        /* Calculate the match value required for our wanted tick rate. */
        ulCompareMatch = configCPU_CLOCK_HZ / configTICK_RATE_HZ;

        /* Protect against divide by zero.  Using an if() statement still results
        in a warning - hence the #if. */
        #if portPRESCALE_VALUE != 0
        {
                ulCompareMatch /= ( portPRESCALE_VALUE + 1 );
        }
        #endif
        T0MR0 = ulCompareMatch;

        /* Generate tick with timer 0 compare match. */
        T0MCR  = ( portRESET_COUNT_ON_MATCH | portINTERRUPT_ON_MATCH);  /* Reset timer on match and generate interrupt */

        /* Setup the VIC for the timer. */
        VICIntSelect &= ~( portTIMER_VIC_CHANNEL_BIT );
        VICIntEnable |= portTIMER_VIC_CHANNEL_BIT;

        /* The ISR installed depends on whether the preemptive or cooperative
        scheduler is being used. */
        #if configUSE_PREEMPTION == 1
        {
                extern void ( vPreemptiveTick )( void );
                VICVectAddr4 = ( portLONG ) vPreemptiveTick;
        }
        #else
        {
                extern void ( vNonPreemptiveTick )( void );
                VICVectAddr4 = ( portLONG ) vNonPreemptiveTick;
        }
        #endif

        VICVectCntl4 = portTIMER_VIC_CHANNEL | portTIMER_VIC_ENABLE;

        /* Start the timer - interrupts are disabled when this function is called
        so it is okay to do this here. */
        T0TCR = portENABLE_TIMER;
}

Interrupt routine (portAsm.s file)

vPreemptiveTick


PRESERVE8
portSAVE_CONTEXT ; Save the context of the current task.
LDR R0, =xTaskIncrementTick ; Increment the tick count. MOV LR, PC ; This may make a delayed task ready BX R0 ; to run.
LDR R0, =vTaskSwitchContext ; Find the highest priority task that MOV LR, PC ; is ready to run. BX R0
MOV R0, #T0MATCHBIT ; Clear the timer event LDR R1, =T0IR STR R0, [R1]
LDR R0, =VICVECTADDR ; Acknowledge the interrupt LDR R1, =0 STR R1,[R0]
portRESTORE_CONTEXT ; Restore the context of the highest ; priority task that is ready to run. END