Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

fiq external interrupt example

fiq external interrupt example

2005-10-21 by bell_c_d

Can anyone point me to some working fiq sample code?  Preferably using 
an external interrupt but any interrupt will probably do.  My fiq 
interrupt handler stops responding after a few hundred interrupts; I'm 
sure it's something I've done and having some known good sample code 
would help figure it out.

Re: fiq external interrupt example

2005-10-21 by Karl Olsen

--- In lpc2000@yahoogroups.com, "bell_c_d" <bell_c_d@y...> wrote:
>
> Can anyone point me to some working fiq sample code?  Preferably
> using an external interrupt but any interrupt will probably do.  My
> fiq interrupt handler stops responding after a few hundred
> interrupts; I'm sure it's something I've done and having some known
> good sample code would help figure it out.

In a project (gcc 3.4) I use both a FIQ and an IRQ.

In main():

  /* Timer 0 is a 5000 Hz timer interrupt using FIQ. */
  SYS->PCONP |= (1<<1);       /* Power on timer 0 */
  VIC->IntEnable = (1<<4);    /* Enable source 4 (timer 0) */
  VIC->IntSelect = (1<<4);    /* Source 4 is FIQ, not IRQ */
  T0->MR0 = PCLK_HZ/TICK_HZ;  /* 10 kHz interrupt frequency */
  T0->MCR = 0x0003;           /* Interrupt and reset on MR0 match */
  T0->TCR = 0x01;             /* Start timer 0 */


The FIQ handler:

void FIQ_Handler (void) __attribute__ ((interrupt("FIQ")));
void FIQ_Handler (void)
{
  ElectrodeTick();
  TaskTick();
  T0->IR = 0x01;   /* Clear the match 0 interrupt flag */
}


In startup.s:

Vectors:
  /* Exception Vectors */
  B   Reset_Handler      /* Reset handler */
  B   Undef_Handler      /* Undefined Instruction handler */
  B   SWI_Handler        /* Software Interrupt handler */
  B   PAbort_Handler     /* Prefetch abort handler */
  B   DAbort_Handler     /* Data abort handler */
  NOP                    /* Checksum, automatically calculated */
  LDR PC, [PC, #-0x0FF0] /* IRQ: Vector from VICVectAddr */
  B   FIQ_Handler        /* FIQ handler */


Karl Olsen

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.