0
0
Embedded Cprogramming~20 mins

SPI vs UART trade-offs in Embedded C - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SPI vs UART Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Data Transfer Speed Comparison

Which statement correctly compares the maximum data transfer speeds of SPI and UART?

ANeither SPI nor UART supports high-speed data transfer.
BUART generally supports higher data transfer speeds than SPI.
CSPI generally supports higher data transfer speeds than UART.
DSPI and UART have the same maximum data transfer speeds.
Attempts:
2 left
💡 Hint

Think about clocked vs asynchronous communication.

Predict Output
intermediate
1:30remaining
UART Data Frame Size

Given the UART configuration below, what is the total number of bits transmitted per data frame (including start, data, parity, and stop bits)?

Embedded C
/* UART config: 1 start bit, 8 data bits, no parity, 1 stop bit */
// Calculate total bits per frame
A8 bits
B9 bits
C11 bits
D10 bits
Attempts:
2 left
💡 Hint

Count all bits including start and stop bits.

Predict Output
advanced
2:00remaining
SPI Chip Select Behavior

Consider this SPI master code snippet controlling two devices. What will be the output on the chip select (CS) pins if the master communicates with device 2?

Embedded C
/*
SPI Master controls two devices:
CS1 = GPIO pin for device 1
CS2 = GPIO pin for device 2
*/

void select_device(int device) {
    if (device == 1) {
        CS1 = 0; // active low
        CS2 = 1;
    } else if (device == 2) {
        CS1 = 1;
        CS2 = 0;
    }
}

select_device(2);
ACS1 = 0, CS2 = 0
BCS1 = 1, CS2 = 0
CCS1 = 0, CS2 = 1
DCS1 = 1, CS2 = 1
Attempts:
2 left
💡 Hint

Remember chip select is active low.

🧠 Conceptual
advanced
1:30remaining
UART vs SPI: Full Duplex Communication

Which statement best describes the full duplex communication capability of UART and SPI?

ASPI supports full duplex communication; UART does not.
BUART supports full duplex communication; SPI does not.
CBoth SPI and UART support full duplex communication.
DNeither SPI nor UART supports full duplex communication.
Attempts:
2 left
💡 Hint

Consider how data lines are used in each protocol.

Predict Output
expert
2:30remaining
UART Baud Rate Error Calculation

Given a UART configured for 9600 baud with a clock frequency of 16 MHz, what is the approximate baud rate error percentage if the UART baud rate register is set to 103?

Embedded C
/*
Baud rate = Clock / (16 * (UBRR + 1))
Clock = 16,000,000 Hz
UBRR = 103
*/

// Calculate actual baud rate and error percentage
AError ≈ 0.06%
BError ≈ 1.2%
CError ≈ 0.5%
DError ≈ 2.0%
Attempts:
2 left
💡 Hint

Calculate actual baud rate then compare to 9600.