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