Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

FIQ Interrupt in LPC2129

kosaaa

Newbie
Newbie level 1
Joined
Feb 12, 2025
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
8
Hi everyone,I'm trying to write code for the FIQ interrupt, but when I trigger the interrupt through the GPIO, it doesn't seem to take the FIQ address. The interrupt action is also not occurring. If anyone knows why this is happening, please let me know.
Code:
#include<lpc21xx.h>
#define led1 1;

void fiq_inter_isr(void) __irq
{
  EXTINT = 0x01;
    IOSET0 = led1;
    IOCLR0 = led1;
    //VICVectAddr =0;
}


int main()
{
    unsigned count =0;
  PINSEL1      = 0X1;
    IODIR0       = led1;
    VICIntSelect = 0x1;
    VICIntEnable = (1<<14);
    EXTMODE      = 0X00;
    EXTPOLAR     = 0X00;
    while(1)
    {
    count++;
  }
}
 
Last edited by a moderator:
Try this way.

Code:
#include <lpc21xx.h>

#define led1 (1 << 1) // Assuming LED is on P0.1

void fiq_inter_isr(void) __attribute__((interrupt("FIQ"))); // Define as FIQ

void fiq_inter_isr(void)
{
    EXTINT = 0x01;   // Clear EINT0 interrupt flag
    IOSET0 = led1;   // Turn LED ON
    for (volatile int i = 0; i < 100000; i++); // Small delay
    IOCLR0 = led1;   // Turn LED OFF
}

int main()
{
    unsigned count = 0;

    // Configure P0.14 as EINT0
    PINSEL0 |= (1 << 29);

    // Configure LED Pin
    IODIR0 |= led1; // Set P0.1 as output

    // Enable FIQ for EINT0
    VICIntSelect |= (1 << 14); // Set EINT0 as FIQ
    VICIntEnable = (1 << 14);  // Enable FIQ interrupt

    // Configure External Interrupt 0
    EXTMODE |= (1 << 0);  // Edge sensitive
    EXTPOLAR &= ~(1 << 0); // Falling edge trigger

    // Enable FIQ mode
    __asm volatile ("mrs r0, cpsr");
    __asm volatile ("bic r0, r0, #0x40"); // Clear FIQ disable bit
    __asm volatile ("msr cpsr, r0");

    while (1)
    {
        count++; // Dummy loop
    }
}
 
but when I trigger the interrupt through the GPIO, it doesn't seem to take the FIQ address.
how did you test this?

****
Try this way.
local variable "i" to be volatile makes no sense. (unless it´s just to prevent the compiler from optimizing it away)
It causes no problems either.
***
The delay counting in ISR should be done for debug only. Don´t use any busy_wait in ISR.
***
variable "count" is not declared. Please do so.

***
count++; does nothing useful. Thus maybe it´s removed by the compiler. Exisitng or not, it will not make any difference anyways.

*************

Indeed I´d use a globally defined variable: volatile uint32_t IsrFlags = 0;

then in ISR:
IsrFlags |= 0x0001;

in main()
IF (IsrFlags > 0) ... < debug.output something>; IsrFlags = 0;

Info: With this you can check in main loop whether the ISR was executed.

*****

Klaus
 

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top