Complete the code to initialize UART baud rate register.
UART_BAUD_REG = [1];The baud rate register value for 9600 baud at 16 MHz clock is 103.
Complete the code to enable UART transmitter.
UART_CTRL_REG |= [1];Bit 2 (0x04) enables the UART transmitter in control register.
Fix the error in the UART receive function to correctly check data ready flag.
if (UART_STATUS_REG & [1]) { received_data = UART_DATA_REG; }
Bit 6 (0x40) is the RX complete flag indicating data is ready to read.
Fill both blanks to create a UART transmit function that waits until ready and sends data.
while (!(UART_STATUS_REG & [1])) {} UART_DATA_REG = [2];
Wait for transmit buffer empty flag (bit 5, 0x20) before writing data to UART_DATA_REG.
Fill all three blanks to create a UART initialization function setting baud rate, enabling transmitter and receiver.
void UART_Init() {
UART_BAUD_REG = [1];
UART_CTRL_REG = [2] | [3];
}Set baud rate register to 103 for 9600 baud, enable transmitter (0x04) and receiver (0x08) bits in control register.