UART - Delay code to wait for User response

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I want to ask the user for several specifications, all just one char inputs; however, the program doesn't wait for the user input and goes along with outputting strings. 

   

 

   

UART_PutString("Welcome");

   

UART_PutSring("Please Enter either A or B");

   

char1 = UART_GetChar();

   

UART_PutString("Please Enter either Z or Y");

   

char2 = UART_GetChar(); 

   

 

   

These are polling for user input once, so it is outside the for(;;). I am using Tera Term and it is connected with a serial of 115200 with 8 data bits. How do I make the program wait till the user inputs data? 

0 Likes
3 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum.

   

Use the UART_GetRxBufferSize() API. It will return != 0 when at least one character is in the buffer.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Thank you Bob. Moreover, my colleague and I wanted to give you an extra thanks for doing all you've done in this community, because we've had plenty of questions throughout the semester and you've been able to point us in the right direction numerous times. Thank you. 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You are always welcome!

   

 

   

Bob

0 Likes