Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to enable the ADC.
Embedded C
ADC->CR2 |= [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ADC_CR2_CONT which enables continuous mode but not interrupt.
Using ADC_CR2_DMA which enables DMA, not interrupt.
Using ADC_CR2_EOCS which configures end of conversion selection.
✗ Incorrect
The ADC_CR2_ADON bit enables the ADC.
2fill in blank
mediumComplete the code to start the ADC conversion.
Embedded C
ADC->CR2 |= [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ADC_CR2_ADON which only enables ADC but does not start conversion.
Using ADC_CR2_EXTTRIG which is for external trigger, not software start.
Using ADC_CR2_DMA which enables DMA, unrelated to start.
✗ Incorrect
ADC_CR2_SWSTART starts the ADC conversion by software.
3fill in blank
hardFix the error in the interrupt handler to clear the ADC interrupt flag.
Embedded C
void ADC_IRQHandler(void) {
if (ADC->SR & [1]) {
uint16_t value = ADC->DR;
// process value
ADC->SR &= ~ADC_SR_EOC;
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Checking ADC_SR_OVR which is overrun flag, not conversion complete.
Checking ADC_SR_AWD which is analog watchdog flag.
Checking ADC_SR_STRT which is start flag, not end.
✗ Incorrect
ADC_SR_EOC is the end of conversion flag that must be checked and cleared.
4fill in blank
hardFill both blanks to configure the NVIC for ADC interrupt with priority 1.
Embedded C
NVIC_SetPriority([1], 1); NVIC_EnableIRQ([2]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated IRQ numbers like TIM2_IRQn or USART1_IRQn.
Mismatching IRQ numbers between priority and enable calls.
✗ Incorrect
ADC_IRQn is the interrupt number for ADC; both priority and enable use it.
5fill in blank
hardFill all three blanks to create a dictionary comprehension that stores ADC values for channels with readings above 1000.
Embedded C
adc_values = { [1]: [2] for [3] in channels if readings[[3]] > 1000 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the opening brace.
Using wrong variable names for keys or values.
Incorrect comprehension syntax.
✗ Incorrect
The dictionary comprehension syntax requires braces, key:value pairs, and iteration variable.