Forum Discussion
Altera_Forum
Honored Contributor
16 years agoDE2 -- UART transmit and receive compiling error
Hi all, I'm using the DE2 kit, with Quartus II (using SOPC) and NIOS IDE software to make an UART communication. But the compilation was always failed. Does anyone know how I can work arou...
Altera_Forum
Honored Contributor
16 years agoI can give you my functions I used to test the Uart. Maybe these can help you to find the problem.
void init_uart(int BAUD) { int divi; divi = (100000000 / BAUD) + 0.5; IOWR_16DIRECT(RS232_INST_BASE, 0x14, divi); } void write_uart(char x) { unsigned long status = 0; while((status & 0x00000040) != 0x00000040) { status = IORD_ALTERA_AVALON_UART_STATUS(RS232_INST_BASE); } IOWR_ALTERA_AVALON_UART_TXDATA(RS232_INST_BASE, x); } char read_uart(void) { char x; x = IORD_ALTERA_AVALON_UART_RXDATA(RS232_INST_BASE); return x; }