Altera_Forum
Honored Contributor
20 years agoProblem detecting data no Serial Port
Hello,
I´ve built the folowing code: while (1) { fprintf(fp, "%c", B_PACK); for (j = 0; j < 10000000; j++) { //testadado = (testadado | tembyte()); // tem dado http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif if(IORD_ALTERA_AVALON_UART_STATUS(ENDSERIAL) & 0x080) { printf("I got data"); testadado = 1; getchar(); break; } } } Where fp is a pointer to my uart1. Well, I´m testing this code with Hyperterminal. I can receive the B_PACK byte there with no problems. But when I send one byte thru the Hyperterminal, the code keeps running and it do not enter in the if(IORD_ALTERA_AVALON_UART_STATUS(ENDSERIAL) & 0x080) condition. If I send a lot of data, then sometimes it enters in the condition. But it do not work to the first data. Can someone help me? And isn´t there another way to detect if there is data on the serial? Thanks!