Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

UART Core with NIOS issue

VCham
New Contributor I
700 Views

I have added the standard UART Core to my Cyclone V Quartus project and have connected it to NIOS. The other end of the UART interface is connected to my computer and I use PuTTY.

 

I am able to transmit and receive, however on receive it takes around 30 seconds of sending data via PuTTY for the FPGA to actually "catch up" and consistently receive the data.

 

both PuTTY and my UART module are set to 115200 baud, odd parity, and 1 stop bit.

 

Here is the test code I'm using.

while(1) { if((IORD(UART_ICT_BASE,0x2) & 0x0080) == 0x0080) { printf("\nreceived data: %4X\n", IORD(UART_ICT_BASE,0x0)); } }

 

0 Kudos
4 Replies
Eliath_G_Intel
Employee
678 Views

Hi Valentina,

First of all, thank you for reaching us. I'm Eliath and I'll help you.

 

The UART core has its own register where you can actually find some flags to know if the buffer is empty or not before trying to read or even sent a message, looking at your code shared in the picture above, I can see that you need to do more validation before running the line #3 ( the print line). To do this I recommend you to use :

  • altera_avalon_uart_rxirq
  • altera_avalon_uart_txirq

Those are interruptions for what I mentioned before.

Or if you prefer... you can check the corresponding flag by polling technique.

This recommendation is to clear the flags after every transaction... the 30 seconds it takes from sending to receive data could be because this time that takes the UART register to be full and make a match with the flag CTS, and after that, you get the expected result.

 

Take a look to this Document. Chapter 11 (UART CORE) section 11.4.1 example 5 and try using that code before doing any other change.

After running the code from the document, you can see in section 11.4.1.1 how the description for the interruptions I recommended above.

 

Please let me know if this information was useful to solve your problem and do not hesitate to let me know any questions you may have!!!

 

Regards!

-Eliath Guzman

0 Kudos
VCham
New Contributor I
678 Views

Hi Eliath,

 

Thanks for the info. However, I was able to solve this without using interrupts by writing 0x0 to the Control Register during initialization. Not sure why that worked but the same script I posted above now consistently receives and prints all bytes that get sent to it.

0 Kudos
Eliath_G_Intel
Employee
678 Views

That's great news!

Please let me know if there is something else I can do for you so I can close the case :)

 

Thanks,

-Eliath Guzman

0 Kudos
VCham
New Contributor I
678 Views

No I'm all set. Thanks

0 Kudos
Reply