Topic : LPC2478 Timer0 interrupt

Forum : ARM

Original Post
Post Information Post
March 8, 2010 - 11:25pm
Guest

Hello,

I'm busy with a Timer interrupt, but it seems not to work and I search a lot in the examples code and have used a lot but nothing likes to work:

Code.h:
void Timer0_irq (void) __attribute__ ((interrupt ("IRQ")));;

Code.c
/**********************************************************
Functie: Timer0 irq
**********************************************************/
void Timer0_irq(void)
{
print("T");

timer0_counter++;
if(timer0_counter == 500)
{
flag_time = 1 << flag_time_500ms;
timer0_counter = 0;

}

T0IR = 1; //Clear interrupt flag
VICVectAddr = 0; //Acknowledge Interrupt
}
/*********************************************************/

/**********************************************************
Functie: Timer0 init
**********************************************************/
void Timer0_init(void)
{
T0MR0 = 12000;
T0MCR = 0x03; //Interupt when MR0 is TC & TC is reset when MR0 matches it

VICVectAddr4 = (U32)Timer0_irq; //Timer0 irq
VICVectCntl4 = 15;
VICIntEnable = (1 << 4); //Enable Timer0 irq

T0TCR = 0x01; //Timer enabeled

return;
}
/*********************************************************/

Can somebody help me?

Kind regards

Patrick

Replies
Post Information Post
+1
0
-1
March 21, 2010 - 7:51am
Guest

I have the exact same problem on a 2368. Does anyone know anything about this?

+1
0
-1
March 22, 2010 - 10:17am
Raisonance Support Team

Hi,

The default startups provided by Ride for the LPC2x devices only call a global IRQ_Handler function.
See their source codes here:
\lib\ARM\LPC2*.s

Then you have to add the code for analyzing which IRQ occured and call the appropriate ISR. (or call the same all the time if your application only uses one IRQ) You should find how to do that in the examples provided by NXP's website. (The examples in Ride are just to allow for testing the debugger. The examples showing the features of the CPUs are provided by the CPU manufacturers.)

More information here:
http://ics.nxp.com/support/documents/microcontrollers/pdf/an10254.pdf

Best Regards,

Vincent

+1
0
-1
October 31, 2010 - 9:12am
Guest

pjwl wrote:
Hello,

I'm busy with a Timer interrupt, but it seems not to work and I search a lot in the examples code and have used a lot but nothing likes to work:

Code.h:
void Timer0_irq (void) __attribute__ ((interrupt ("IRQ")));;

Code.c
/**********************************************************
Functie: Timer0 irq
**********************************************************/
void Timer0_irq(void)
{
print("T");

timer0_counter++;
if(timer0_counter == 500)
{
flag_time = 1 << flag_time_500ms;
timer0_counter = 0;

}

T0IR = 1; //Clear interrupt flag
VICVectAddr = 0; //Acknowledge Interrupt
}
/*********************************************************/

/**********************************************************
Functie: Timer0 init
**********************************************************/
void Timer0_init(void)
{
T0MR0 = 12000;
T0MCR = 0x03; //Interupt when MR0 is TC & TC is reset when MR0 matches it

VICVectAddr4 = (U32)Timer0_irq; //Timer0 irq
VICVectCntl4 = 15;
VICIntEnable = (1 << 4); //Enable Timer0 irq

T0TCR = 0x01; //Timer enabeled

return;
}
/*********************************************************/

Can somebody help me?

Kind regards

Patrick

hi,
I am also facing same problem and lot of working on that but can't solved yet
have you solved this problem,
could you help me?

regards,
Amogh

+1
0
-1
October 31, 2010 - 4:50pm
Guest

Hi Amogh,

It's been a while since I worked on this but I seem to remember having it working at some point. My code is as follows (in Raisonance Ride 7): (it may or may not be a copy of sample code, I just can't remember)


#include 

void IRQ_Handler (void) __attribute__ ((interrupt ("IRQ")));;

extern volatile unsigned int time;

void IRQ_Handler(void)
{
  time++;
  
  T0IR = 0x3;         // clear interrupt flag
  VICVectAddr = 0xFF;
}

void init_timer ( unsigned int TimerInterval ) 
{
  T0TCR = 2; // reset counters
  T0TCR = 0; // disable timer
  
  T0PR = TimerInterval;
  
  T0MR0 = 1000;
  T0MCR = 0x3;
  
  VICIntSelect &= ~(0x10); // Timer 0 selected as IRQ
  VICIntEnable |= 0x10; // Timer 0 interrupt enabled
  VICVectPriority0 = 1; // set priority for timer 0 to be quite high
  VICVectAddr0 = (unsigned long)IRQ_Handler;
  
  T0TCR = 1;
}


main()
{
  configRCC();
  
  //Disable ETM interface, enable IOs
  PINSEL10 = 0;
  
  // Make timer operate at correct speed
  PCLKSEL0 &= ~(0x3 << 2);
  PCLKSEL0 |= (0x1 << 2);
  
  init_timer(72000 - 1);
  
  FIO2DIR  = 0x7;
  FIO2MASK = ~(0x7);
  
  
  while(1)
  {
    if(time > nextTime)
    {
      FIO2CLR = 0x7;
      
      FIO2SET = time % 8;
      
      nextTime = time;
    }
  }
}

No guarantees though!