Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to activate the chip select line.
Embedded C
GPIO_WritePin(GPIOA, [1], GPIO_PIN_RESET); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong GPIO pin number.
Setting the pin to GPIO_PIN_SET instead of GPIO_PIN_RESET.
✗ Incorrect
The chip select line is connected to GPIO_PIN_4, so setting it low activates the chip.
2fill in blank
mediumComplete the code to deactivate the chip select line.
Embedded C
GPIO_WritePin(GPIOA, GPIO_PIN_4, [1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using GPIO_PIN_RESET instead of GPIO_PIN_SET.
Using undefined constants like GPIO_PIN_HIGH.
✗ Incorrect
Setting the chip select pin high deactivates the chip.
3fill in blank
hardFix the error in the chip select initialization code.
Embedded C
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = [1];
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Initializing the wrong GPIO pin.
Forgetting to initialize the chip select pin.
✗ Incorrect
The chip select pin is GPIO_PIN_4, so it must be set in the initialization.
4fill in blank
hardFill both blanks to create a function that activates and then deactivates chip select.
Embedded C
void ChipSelectControl() {
GPIO_WritePin(GPIOA, [1], GPIO_PIN_RESET);
HAL_Delay(10);
GPIO_WritePin(GPIOA, [2], GPIO_PIN_SET);
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different pins for activation and deactivation.
Using pins other than GPIO_PIN_4.
✗ Incorrect
The chip select pin is GPIO_PIN_4 for both activation and deactivation.
5fill in blank
hardFill all three blanks to implement a safe chip select toggle with delay and pin initialization.
Embedded C
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = [1];
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_WritePin(GPIOA, [2], GPIO_PIN_RESET);
HAL_Delay(5);
GPIO_WritePin(GPIOA, [3], GPIO_PIN_SET); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different pins in initialization and toggling.
Forgetting to initialize the chip select pin.
✗ Incorrect
All operations use GPIO_PIN_4 for chip select initialization and toggling.