Altera_Forum
Honored Contributor
20 years agointerrupt handling for UART
hello everyone.
I am trying to send and receive data between UART on UP3 and hyperterminal. But am not able to set the interrupts properly and as a result my program goes in an infinite loop. here is a part of my code....could u plz tell me what else needs to be added to the code so that an interrupt is generated when some data comes on the serial port.. int main(void) { int led = 0x01; int ch = 0; FILE *fd; /* Initialise the interrupt controller. */ alt_irq_init (ALT_IRQ_BASE); IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE,led); // write initial value to pio /* initialise the device drivers/software components*/ alt_sys_init(); # ifdef UART_BASE fd = fopen("/dev/uart", "r+"); # endif if(fd){ while(1){ if(FLAG_READ){ /* it is set inside the alt_avalon_uart_rxirq() function when some data is received */ alt_avalon_uart_read(fd,ch,sizeof(int)); break; } // end of if } // end of while } // end of if if(ch == 'a') led = 0x02; else led = 0x04; IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE,led); // write new value to pio fclose(fd); } whenever i run this code it doesnt come out of the while loop even when i type something on the hyperterminal. Plz helo me out thnx sourabh goel