Forum Discussion
Altera_Forum
Honored Contributor
20 years ago --- Quote Start --- originally posted by hoffpistolao@Dec 21 2005, 08:27 AM 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!
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=11692)
--- quote end ---
--- Quote End --- Hello, maybe the problem here is that you are using high-level HAL functions with low-level macros (driver level) to access your UART. If you only use one of these methods, it should work. May be if you fclose() the UART before using the low-level macros could help. We had a similar problem because we wanted to use the high-level HAL functions only, but then the getchar() function blocked until there was data received. So we decided to write our own UART driver with a non-blocking read() function. I hope this helps!