The following code is the code for UART receving
Char uart_receive {
While( ! ( UCSRA & ( 1 << RXC ) ) );
return UDR;
}
This function will not return the UDR value until the while loop breaks because its expression evaluates to zero.
My question is: When there is a byte in the receiving buffer,the RXC= 1, so the while loop will be while(1) and it will be infinite loop ,so the function will not return the UDR value.... can any one help me to understand this?
while ( true )
, notwhile ( 1 )
.... when the logic evaluation becomes false then the while loop exits – jsotola Oct 14 '20 at 15:21!
negates the 1 (which is a trueish value) to a false. Then the while loop exists. If the expression after the `!' evaluates to 0 that's a falsy value and the '!' negates it to true. – Peter Paul Kiefer Oct 14 '20 at 15:44