0
0
Embedded Cprogramming~10 mins

I2C vs SPI decision matrix in Embedded C - Interactive Practice

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

Complete the code to initialize an I2C communication with the correct clock speed.

Embedded C
I2C_Init([1]);
Drag options to blanks, or click blank then click option'
A100000
B500000
C1000000
D2000000
Attempts:
3 left
💡 Hint
Common Mistakes
Using SPI clock speeds instead of I2C speeds.
2fill in blank
medium

Complete the code to select the SPI mode that supports full-duplex communication.

Embedded C
SPI_SetMode([1]);
Drag options to blanks, or click blank then click option'
ASPI_MODE_0
BSPI_MODE_1
CSPI_MODE_2
DSPI_MODE_3
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing SPI modes with half-duplex modes.
3fill in blank
hard

Fix the error in the code to correctly read a byte from an I2C device.

Embedded C
uint8_t data = I2C_ReadByte([1]);
Drag options to blanks, or click blank then click option'
Agpio_pin
Bspi_channel
Cdevice_address
Dbaud_rate
Attempts:
3 left
💡 Hint
Common Mistakes
Passing SPI channel or GPIO pin instead of device address.
4fill in blank
hard

Fill both blanks to create a decision matrix entry for choosing SPI over I2C.

Embedded C
if (speed > [1] && devices > [2]) {
    use_spi = true;
}
Drag options to blanks, or click blank then click option'
A400000
B5
C10
D100000
Attempts:
3 left
💡 Hint
Common Mistakes
Using I2C speed values or wrong device count.
5fill in blank
hard

Fill all three blanks to complete the function that decides between I2C and SPI based on speed, device count, and wiring complexity.

Embedded C
bool choose_spi(int speed, int devices, int wiring_complexity) {
    if (speed > [1] && devices > [2] && wiring_complexity < [3]) {
        return true;
    } else {
        return false;
    }
}
Drag options to blanks, or click blank then click option'
A400000
B3
C10
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing device count and wiring complexity values.