Hi all,
I am trying to use UART with interrupt on a NIOS II/e system but it seems like the interrupt never occurs.
Before main(), I declare the pointer and the ISR:
Inside main(), I have the following instructions:
And this is the definition of the ISR:
---
This is what I have in the alt_sys_init.c file
And here's the UART configuration from system.h file:
Is there anything I am missing? Why does the UART interrupt never occur?
I am trying to use UART with interrupt on a NIOS II/e system but it seems like the interrupt never occurs.
Before main(), I declare the pointer and the ISR:
Code:
alt_fd* fd="/dev/uart_0";
void get_response(void*, alt_u32); // UART ISR declaration
Code:
fd = open("/dev/uart_0", O_RDWR | O_NOCTTY);
alt_irq_register(UART_0_IRQ,NULL,get_response);
IOWR_ALTERA_AVALON_UART_CONTROL(uart_0, 0x80);
Code:
void get_response(void* context, alt_u32 id){
char tmp;
int status;
status = IORD_ALTERA_AVALON_UART_STATUS(uart_0);
printf("Status = %d ",status);
/* clear any error flags */
IOWR_ALTERA_AVALON_UART_STATUS(uart_0, 0);
tmp = IORD_ALTERA_AVALON_UART_RXDATA(uart_0);
printf("Received char %c\n",tmp);
...
}
This is what I have in the alt_sys_init.c file
Code:
void alt_irq_init ( const void* base )
{
ALTERA_NIOS2_IRQ_INIT ( CPU_0, cpu_0);
alt_irq_cpu_enable_interrupts();
}
/*
* Initialize the non-interrupt controller devices.
* Called after alt_irq_init().
*/
void alt_sys_init( void )
{
ALTERA_AVALON_JTAG_UART_INIT ( JTAG_UART_0, jtag_uart_0);
ALTERA_AVALON_SYSID_INIT ( SYSID, sysid);
ALTERA_AVALON_UART_INIT ( UART_0, uart_0);
}
Code:
/*
* uart_0 configuration
*
*/
#define ALT_MODULE_CLASS_uart_0 altera_avalon_uart
#define UART_0_BASE 0x1009000
#define UART_0_BAUD 9600
#define UART_0_DATA_BITS 8
#define UART_0_FIXED_BAUD 1
#define UART_0_FREQ 50000000u
#define UART_0_IRQ 0
#define UART_0_IRQ_INTERRUPT_CONTROLLER_ID 0
#define UART_0_NAME "/dev/uart_0"
#define UART_0_PARITY 'N'
#define UART_0_SIM_CHAR_STREAM ""
#define UART_0_SIM_TRUE_BAUD 0
#define UART_0_SPAN 32
#define UART_0_STOP_BITS 1
#define UART_0_SYNC_REG_DEPTH 2
#define UART_0_TYPE "altera_avalon_uart"
#define UART_0_USE_CTS_RTS 0
#define UART_0_USE_EOP_REGISTER 0
Is there anything I am missing? Why does the UART interrupt never occur?