Forum Discussion
Altera_Forum
Honored Contributor
11 years ago --- Quote Start --- How are you UART? are you polling or using interrupts? I recommend using interrupts: look at the following thread - the code provided in this thread works well... http://www.alteraforum.com/forum/showthread.php?t=17224 I've used this code to communicate with a visual c++ program on the pc. I think the matlab code for accessing the serial port is correct, so the problem is probably on the FPGA side. --- Quote End --- Hi Krasner, Thanks for your reply. I dont understand why it is not working, must it be done with interrupts? Couldn't it be done by using iowr on the uart? I used the following code to access the UART (rs232 serial port) component I created in Qsys, I connected the txdata pin to the oscilloscope and it shows nothing, i am wondering why couldn't I use IOWR_ALTERA_AVALON_UART_TXDATA(UART_BASE, txdata); to transmit data to UART? What I want to do is Nios processor reads data from FPGA, Nios transmits the data to serial port and plot graph real time using Maltab,using de0 nano. I do not need to read data from serial port. #include "altera_avalon_uart_regs.h" #define UART_BASE 0x00002000 int main (void) {alt_u16 status, rxdata=0,aa=0, txdata=0; while (! (status & 0x0040)) // Wait for transmission completion status = IORD_ALTERA_AVALON_UART_STATUS (UART_BASE); printf("status= %.2f V \r\n", (float) status); rxdata = 5; // assuming I get this data by accessing sdram in Nios txdata = rxdata; IOWR_ALTERA_AVALON_UART_TXDATA(UART_BASE, txdata); printf("txdata= %.2f V \r\n", (float) txdata); return 0;} Could you please give me some hints? Thanks