Forum Discussion

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

UART RECEIVE interrupt in nios int status = 0; status = IORD_ALTERA_AVALON_UART_STAT

Hello,

I need to read the uart data on interrupt bases ,means whenever there is something on rx pin of uart interrupt should get generated and in ISR should read it.

I have tried by using bellow code but didn't get any success ...

char data;

volatile int edge_capture;

void uart_isr()

{

int status = 0; status = IORD_ALTERA_AVALON_UART_STATUS(UART_0_BASE);

if(status & 0x80)

data = IORD_ALTERA_AVALON_UART_RXDATA(UART_0_BASE);

interrupt_count = interrupt_count +1;

}

void uart()

{

void* edge_capture_ptr = (void*) &edge_capture;

alt_ic_isr_register(UART_0_IRQ_INTERRUPT_CONTROLLER_ID,

UART_0_IRQ, uartR, edge_capture_ptr, 0x0);

alt_ic_irq_enable(UART_0_IRQ_INTERRUPT_CONTROLLER_ID,UART_0_IRQ);

IOWR_ALTERA_AVALON_UART_CONTROL(UART_0_BASE,ALTERA_AVALON_UART_CONTROL_RRDY_MSK);

}

sometime ISR just gets called once and sometime it will be keep getting even if there is nothing on uart RX bus..

M i doing something wrong here ..plz suggest me.

If anyone has example code for uart interrupt receive plz share .

Thanks and Regards

Ankur
No RepliesBe the first to reply