0
0
Embedded Cprogramming~10 mins

Why SPI is used in Embedded C - Test Your Understanding

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

Complete the code to define SPI as a communication protocol.

Embedded C
const char* protocol = "[1]";
Drag options to blanks, or click blank then click option'
AUSB
BUART
CI2C
DSPI
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing SPI with UART or I2C protocols.
2fill in blank
medium

Complete the code to initialize SPI clock speed.

Embedded C
SPI_InitTypeDef SPI_InitStruct;
SPI_InitStruct.ClockSpeed = [1];
Drag options to blanks, or click blank then click option'
A9600
B1000000
C115200
D50000000
Attempts:
3 left
💡 Hint
Common Mistakes
Using UART baud rates instead of SPI clock speed.
3fill in blank
hard

Fix the error in SPI data transfer function call.

Embedded C
uint8_t received = SPI_TransmitReceive([1], 0xFF);
Drag options to blanks, or click blank then click option'
Abuffer
BNULL
Cdata
D0xFF
Attempts:
3 left
💡 Hint
Common Mistakes
Passing constant 0xFF instead of variable data.
4fill in blank
hard

Fill both blanks to create a dictionary of SPI pins and their functions.

Embedded C
const char* spi_pins[] = {"MOSI", "MISO", "[1]", "[2]"};
Drag options to blanks, or click blank then click option'
ASCLK
BCS
CCLK
DGND
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing GND or CLK with SPI signal pins.
5fill in blank
hard

Fill all three blanks to complete the SPI data transfer loop.

Embedded C
for (int [1] = 0; [1] < [2]; [1]++) {
    buffer[[1]] = SPI_TransmitReceive(data[[1]]);
}
Drag options to blanks, or click blank then click option'
Ai
Blength
Ccount
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variables inconsistently in the loop.