Forum Discussion
Altera_Forum
Honored Contributor
14 years agoFIFOed UART BSP errors
Hello, I am trying to use the FIFOed UART for Nios rev 9.3 and have instantiated the module successfully in SOPC builder. I generated SOPC and compiled Quartus successfully. I am trying to i...
Altera_Forum
Honored Contributor
14 years agoyou have to defined functions, registers, ...
I use altera IO function so I have included this file. # include "fifoed_avalon_uart_regs.h" an example to use the fifoeduart (read/write) : void WriteCharUART(alt_u8 ch) { IOWR_FIFOED_AVALON_UART_TXDATA(USB_FIFO_UART_BASE,ch); while (!(IORD_FIFOED_AVALON_UART_STATUS(USB_FIFO_UART_BASE) & 0x0040)); // while trdy==0 } void WriteSentenceUART(char* text) { int temp = 0; while (text[temp] != '\0') { WriteCharUART(text[temp]); temp++; if (temp == 100) return; } } void handle_io_uart_interrupts(void* context, alt_u32 id) { char tmp_buff; // you can use "context" as a parameter tmp_buff = IORD_FIFOED_AVALON_UART_RXDATA(USB_FIFO_UART_BASE); if (tmp_buff>=0x20) printf("| %c ", tmp_buff); else printf("| 0x%X ", tmp_buff); } int main() { int ctrl; // IRQ off IOWR_FIFOED_AVALON_UART_CONTROL(USB_FIFO_UART_BASE, 0); // init program … // init uart IOWR_FIFOED_AVALON_UART_CONTROL(USB_FIFO_UART_BASE, 128); // Enable interrupt for a read ready = caractere receive alt_irq_register(USB_FIFO_UART_IRQ, (void *)&ctrl, handle_io_uart_interrupts); while (1) { } return 0; }