0
0
Embedded Cprogramming~10 mins

UART protocol fundamentals in Embedded C - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize UART baud rate register.

Embedded C
UART_BAUD_REG = [1];
Drag options to blanks, or click blank then click option'
A103
B9600
C115200
D0xFF
Attempts:
3 left
💡 Hint
Common Mistakes
Using baud rate number directly instead of register value.
2fill in blank
medium

Complete the code to enable UART transmitter.

Embedded C
UART_CTRL_REG |= [1];
Drag options to blanks, or click blank then click option'
A0x08
B0x04
C0x10
D0x01
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing transmitter enable with receiver enable bits.
3fill in blank
hard

Fix the error in the UART receive function to correctly check data ready flag.

Embedded C
if (UART_STATUS_REG & [1]) {
    received_data = UART_DATA_REG;
}
Drag options to blanks, or click blank then click option'
A0x20
B0x80
C0x40
D0x10
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong status flag bit causing missed data reception.
4fill in blank
hard

Fill both blanks to create a UART transmit function that waits until ready and sends data.

Embedded C
while (!(UART_STATUS_REG & [1])) {}
UART_DATA_REG = [2];
Drag options to blanks, or click blank then click option'
A0x20
Bdata
C0x80
D0x40
Attempts:
3 left
💡 Hint
Common Mistakes
Waiting on wrong flag or writing wrong variable to data register.
5fill in blank
hard

Fill all three blanks to create a UART initialization function setting baud rate, enabling transmitter and receiver.

Embedded C
void UART_Init() {
    UART_BAUD_REG = [1];
    UART_CTRL_REG = [2] | [3];
}
Drag options to blanks, or click blank then click option'
A103
B0x04
C0x08
D9600
Attempts:
3 left
💡 Hint
Common Mistakes
Using baud rate number directly, forgetting to enable both transmitter and receiver.