c8051f350串口通信(5)
发布时间:2021-06-07
发布时间:2021-06-07
串口通信
if (TI0 == 1) // Check if transmit flag is set
{
TI0 = 0; // Clear interrupt flag
if (UART_Buffer_Size != 1) // If buffer not empty
{
// If a new word is being output
if ( UART_Buffer_Size == UART_Input_First )
{
UART_Output_First = 0;
}
Byte = UART_Buffer[UART_Output_First]; // Store a character in the variable byte
if ((Byte >= 0x61) && (Byte <= 0x7A)) // If upper case letter
{
Byte -= 32;
}
SBUF0 = Byte; // Transmit to Hyperterminal
UART_Output_First++; // Update counter
UART_Buffer_Size--; // Decrease array size
}
else
{
UART_Buffer_Size = 0; // Set the array size to 0
TX_Ready = 1; // Indicate transmission complete
}
}
}