Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

Unresolved Inclusion, priv

Good day forum People

I am a total noob to nios2. I am trying to run a uart IRQ but because of an unresolved inclusion: My main c files code is:

# include "system.h"# include "altera_avalon_uart_regs.h"# include "sys/alt_irq.h"# include <stdio.h># include "altera_avalon_pio_regs.h"# include <alt_types.h>
# define RX_BUFFER_SIZE 1024
unsigned char rx_buffer;
void IsrUart()
{
    IOWR_ALTERA_AVALON_UART_TXDATA(UART_BASE,0x03);
    int sr;
    IOWR_ALTERA_AVALON_PIO_DATA(OUT_8PIO_BASE,0x2);
    sr = IORD_ALTERA_AVALON_UART_STATUS(UART_BASE);
    if(sr & ALTERA_AVALON_UART_STATUS_RRDY_MSK)
    {
        rx_buffer=IORD_ALTERA_AVALON_UART_RXDATA(UART_BASE);
    }
    IOWR_ALTERA_AVALON_UART_RXDATA(UART_BASE,rx_buffer);
    if (rx_buffer==0x55)
        IOWR_ALTERA_AVALON_PIO_DATA(OUT_8PIO_BASE,rx_buffer);
}
void InitUart()
{
    IOWR_ALTERA_AVALON_UART_TXDATA(UART_BASE,0x02);
int context_uart;
alt_irq_register(UART_IRQ,&context_uart,IsrUart);
alt_irq_enable (UART_IRQ);
}
int main(void)
{
    IOWR_ALTERA_AVALON_UART_TXDATA(UART_BASE,0x01);
    InitUart();
    IOWR_ALTERA_AVALON_PIO_DATA(OUT_8PIO_BASE,0x00);
while(1)
{
    usleep(1000000);
    IOWR_ALTERA_AVALON_UART_TXDATA(UART_BASE,0x11);
}
return 0;
}
Every time I try to build it I get the error:

undefined reference to `alt_irq_enable'

I've traced it all the way through alt_irq.h and found that the function is declared in alt_legacy_irq.h which is included in alt_irq. If I manually go and get this file and included it the error goes away but my interrupt never gets executed. Any help would be much appreciated.

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hello,

    You did not configure the control register of the UART to specify which interrupt you want to activate (cf Embedded Peripherals IP User Guide pp 7-11 to 7-15). So it is normal that the ISR is never executed.

    Regarding the function alt_irq_enable, you don't need it, by default the interrupts are active. You need this function only if you want to deativate an interrupt and reactivate it later.

    Jérôme