Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to send a byte using UART.
Embedded C
void UART_SendByte(char data) {
while (!(UART_STATUS & [1]));
UART_DATA = data;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the receiver ready flag instead of transmitter ready.
Checking for error flags instead of readiness.
✗ Incorrect
The UART_TX_READY flag indicates the transmitter is ready to send data.
2fill in blank
mediumComplete the code to wait until UART is ready before sending.
Embedded C
void UART_SendByte(char data) {
while ((UART_STATUS & [1]) == 0);
UART_DATA = data;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Checking the wrong UART status flag.
Using equality instead of bitwise AND.
✗ Incorrect
Waiting for UART_TX_READY flag ensures the transmitter is ready before sending.
3fill in blank
hardFix the error in the UART byte transmission code.
Embedded C
void UART_SendByte(char data) {
while (UART_STATUS & [1]);
UART_DATA = data;
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Waiting for the ready flag instead of the busy flag.
Using receiver flags instead of transmitter flags.
✗ Incorrect
Waiting while UART_TX_BUSY is set ensures the transmitter is free before sending.
4fill in blank
hardFill both blanks to create a UART send function that waits for transmitter ready and then sends data.
Embedded C
void UART_SendByte(char data) {
while (!(UART_STATUS & [1]));
UART_DATA = [2];
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using receiver ready flag instead of transmitter ready.
Assigning the wrong variable to UART_DATA.
✗ Incorrect
Wait for UART_TX_READY flag and then assign the data variable to UART_DATA register.
5fill in blank
hardFill all three blanks to implement UART byte transmission with a busy wait and data assignment.
Embedded C
void UART_SendByte(char data) {
while (UART_STATUS & [1]);
UART_DATA = [2];
UART_STATUS |= [3];
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not waiting for the busy flag before sending.
Not clearing the interrupt flag after transmission.
✗ Incorrect
Wait while UART_TX_BUSY is set, assign data, then clear the interrupt flag by setting UART_TX_INTERRUPT_FLAG.