Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize SPI as master.
Embedded C
SPI_InitTypeDef SPI_Config;
SPI_Config.Mode = [1];
// Other configurations follow Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing slave mode instead of master mode.
✗ Incorrect
The SPI must be set to master mode to control the communication.
2fill in blank
mediumComplete the code to set the SPI clock polarity to idle low.
Embedded C
SPI_Config.CLKPolarity = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing polarity high with idle low.
✗ Incorrect
Idle low means clock polarity low, so use SPI_POLARITY_LOW.
3fill in blank
hardFix the error in the SPI data size configuration.
Embedded C
SPI_Config.DataSize = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unsupported data sizes like 32-bit or 4-bit.
✗ Incorrect
SPI commonly uses 8-bit data size; 32-bit or 4-bit are invalid here.
4fill in blank
hardFill both blanks to configure SPI clock phase and NSS management.
Embedded C
SPI_Config.CLKPhase = [1]; SPI_Config.NSS = [2];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing clock phase edges or using hardware NSS when software is needed.
✗ Incorrect
Clock phase is set to first edge, and NSS is managed by software.
5fill in blank
hardFill all three blanks to create a dictionary mapping SPI pins to their functions.
Embedded C
const char* SPI_Pins[] = {"MOSI", "MISO", "SCK"};
const int PinNumbers[] = [1], [2], [3]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up pin numbers or using pins not assigned to SPI.
✗ Incorrect
Common SPI pins are SCK=5, MISO=6, MOSI=7 on many microcontrollers.