0
0
Embedded Cprogramming~10 mins

UART interrupt-driven communication 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 enable UART receive interrupt.

Embedded C
UART->CR1 |= [1];
Drag options to blanks, or click blank then click option'
AUART_CR1_TXEIE
BUART_CR1_RXNEIE
CUART_CR1_TE
DUART_CR1_RE
Attempts:
3 left
💡 Hint
Common Mistakes
Using UART_CR1_TXEIE which enables transmit interrupt instead of receive.
Using UART_CR1_TE or UART_CR1_RE which enable transmitter or receiver but not interrupts.
2fill in blank
medium

Complete the code to clear the UART receive interrupt flag inside the ISR.

Embedded C
if (UART->ISR & UART_ISR_RXNE) {
    uint8_t data = UART->RDR;
    UART->ICR = [1];
}
Drag options to blanks, or click blank then click option'
AUART_ICR_IDLECF
BUART_ICR_RXNECF
CUART_ICR_ORECF
DUART_ICR_TCCF
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to clear RXNE flag manually which is cleared by reading RDR.
Clearing unrelated flags like IDLE or transmission complete.
3fill in blank
hard

Fix the error in the UART interrupt handler to correctly read received data.

Embedded C
void USART1_IRQHandler(void) {
    if (UART->ISR & [1]) {
        uint8_t received = UART->RDR;
        process(received);
    }
}
Drag options to blanks, or click blank then click option'
AUART_ISR_TXE
BUART_ISR_PE
CUART_ISR_TC
DUART_ISR_RXNE
Attempts:
3 left
💡 Hint
Common Mistakes
Using TXE which is transmit data register empty flag.
Using TC which is transmission complete flag.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps received bytes to their ASCII codes only if the byte is a letter.

Embedded C
received_map = {byte: ord(byte) for byte in buffer if byte [1] [2]
Drag options to blanks, or click blank then click option'
A>=
B'a'
C'A'
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' instead of '>=' causing wrong filtering.
Using 'a' which is lowercase and misses uppercase letters.
5fill in blank
hard

Fill all three blanks to build a dictionary comprehension that maps uppercase letters to their ASCII codes only if the code is less than 91.

Embedded C
uppercase_map = { [1] : [2] for [3] in buffer if ord([3]) < 91 }
Drag options to blanks, or click blank then click option'
Achar
Bord(char)
Dbyte
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.
Not using ord() for the value.