Forum Discussion
Altera_Forum
Honored Contributor
12 years agoISR driven UART is missing characters (even at 9600bps... same prob at 230400)
Any ideas on what I'm missing here that is causing me to miss characters? I'm interfacing to a device that shoots out RS232 packets (up to 200 per second if the bps can handle itI can select t...
Altera_Forum
Honored Contributor
12 years agoHi David,
i dont understand your problem, but your code for uart was the first, which works me. Thank you. (i have had problem in Quartus 12, NIOS2 EDS 12 that the# include <sys/alt_irq.h> didnt know these commands alt_irq_register(UART1_IRQ,&context_uart1,IsrUart1 ); // install UART1 ISR alt_irq_enable (UART1_IRQ); When i use your init_uart and handle routine, it works: // obsluha preruseni od uartu1 void IsrUart1(void* context, unsigned long id) { int ch; ch = IORD_ALTERA_AVALON_UART_STATUS(UART_1_BASE); // printf("Jsem v preruseni=%X\n",ch); // pokud prisel znak, precti jej if (ch & ALTERA_AVALON_UART_STATUS_RRDY_MSK) { ch = IORD_ALTERA_AVALON_UART_RXDATA(UART_1_BASE); // printf("Ctu znak=%X\n",ch); IOWR_ALTERA_AVALON_UART_STATUS(UART_1_BASE, 0); if (ch==GPS_PREFIX) rx_start=1; if (rx_start==1) { rx_buf[rx_cnt]= ch; if (rx_cnt<RX_BUF) rx_cnt++; if (rx_cnt==RX_BUF) { rx_flag=1; rx_start=0; } } } } // inicializace preruseni od uartu1 void init_uart1() { alt_irq_init (ALT_IRQ_BASE); // alt_sys_init(); // // nastav 9600Bd pro NIOS2 na 80MHz IOWR_ALTERA_AVALON_UART_DIVISOR(UART_1_BASE, 8334); IOWR_ALTERA_AVALON_UART_CONTROL(UART_1_BASE, ALTERA_AVALON_UART_CONTROL_RRDY_MSK); alt_ic_isr_register(UART_1_IRQ_INTERRUPT_CONTROLLER_ID,UART_1_IRQ,IsrUart1,0,0); // povol preruseni od uartu1 alt_ic_irq_enable(UART_1_IRQ_INTERRUPT_CONTROLLER_ID,UART_1_IRQ); } Thanks. Jan, Czech Republic