My UART keeps sending data out after a character is received. May I know how to do so that, when i send once, it will receive once without ussing interrupt if possible?
if(DataRdyUSART()) // This means 'loop here until we get a new character in the receive buffer'
{
data = getcUSART();
if (data=='A'){
putsUSART( mybuff );
}
#if 0
else if ( data == 'b'){
putsUSART( mybuff1);
}
else
putcUSART(data);
#endif
}
else {
if (data=='A'){
if (flag == 1){
putsUSART( mybuff );
flag=0;
}
}
}
}
CloseUSART();
}
I need it to repeat the displayed message according to the number that the user key in in the hyperterminal . Thanks
No it doesn't. The program won't wait here until data is ready. It data isn't ready, it'll jump to this code:
Code:
else {
if (data=='A'){
You need to pay much more attention to your brackets and program branches! If you want a loop that will wait for an event, the way to do that is like this:
Code:
...
if(!(DataRdyUSART())){}' // This means 'loop here until we get a new character in the receive buffer'
else ......
Or even better:
Code:
while(!(DataRdyUSART())){}' // This means 'loop here until we get a new character in the receive buffer'