Strange Behavior of Timer in LPC2468

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Strange Behavior of Timer in LPC2468

342 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Italia on Mon Jul 21 11:53:08 MST 2014
Hi,

i'm using LPCXpresso and LPC-link programmer with LPC2468 CPU. I wrote the following code, and i have a strange behavior of timer. When i debug step by step the timer takes random values ​​to each advancement of step. That means that i pass from 0x002 to 0x6788 and later to 0x10 and so on.
Can someone say me an example of the ISR hangling in LPCXpresso using Timer0??


I post the code:

void delayMS(unsigned int milliseconds);
void initClocks(void);
void initTimer0(void);
void T0_Interrupt(void);

void setupPLL0(void);
void feedSeq(void);
void connectPLL0(void);

unsigned int i=0;

int main(void)
{
    initClocks(); //Initialize CPU and Peripheral Clocks @ 60Mhz
    initTimer0(); //Initialize Timer0

    IO0DIR = 0xFFFFFFFF; //Configure all pins on Port 0 as Output
    IO0PIN = 0xF;
  
    T0TCR = 0x01; //Enable timer

    i++; //Only to test timer instrucion by instruction
    i++;
    i++;
    i++;
    while(1); //Infinite Idle Loop
}

void initTimer0(void)
{
    T0CTCR = 0x0;

    T0PR = 0;

    T0MR0 = DELAY_MS-1;

    T0MCR = MR0I | MR0R; //Set bit0 & bit1 to High which is to : Interrupt & Reset TC on MR0 

    //----------Setup Timer0 Interrupt-------------

    VICVectAddr4 = (void*)T0_Interrupt; //Pointer Interrupt Function (ISR)

   
    VICIntEnable = 0x10; //Enable timer0 int

    T0TCR = 0x02; //Reset Timer
}

__attribute__ ((interrupt ("irq")))
void T0_Interrupt(void)
{
    long int regVal;
    regVal = T0IR; //Read current IR value
      
    T0IR = regVal; //Write back to IR to clear Interrupt Flag
}

Labels (1)
0 Kudos
2 Replies

297 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Italia on Tue Jul 22 00:56:35 MST 2014
Ok Tahnk u for u reply! Just a last question. When i reset the timer Flag by the instruction:

        T0IR = 1;

The IR bit is not reset.
0 Kudos

297 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Mon Jul 21 13:55:56 MST 2014
The timer doe not stop while you are debugging, so what you are seeing is just the latest value of the timer.
0 Kudos