--- Quote Start ---
originally posted by sourabhgoel83@Sep 9 2005, 07:41 PM
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
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=9658)
--- quote end ---
--- Quote End ---
Hi sourabh goel,
Why don't you try
an284 on
www.altera.com ?
Note : This application note was written for NIOS system. If you are using NIOSII , you would have to convert some of the functions to be NIOSII-compatible.
You can reference to
an350 to do it.
Good luck,
Quan