0
0
Embedded Cprogramming~10 mins

ADC conversion process (sample and hold) in Embedded C - Interactive Code Practice

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

Complete the code to start the ADC conversion.

Embedded C
ADC_StartConversion([1]);
Drag options to blanks, or click blank then click option'
AADC_CHANNEL_0
BADC_CHANNEL_3
CADC_CHANNEL_2
DADC_CHANNEL_1
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong channel number
Forgetting to specify channel
2fill in blank
medium

Complete the code to enable the ADC sample and hold feature.

Embedded C
ADC_ControlRegister |= [1];
Drag options to blanks, or click blank then click option'
AADC_CONVERSION_START
BADC_SAMPLE_ENABLE
CADC_SAMPLE_HOLD_ENABLE
DADC_INTERRUPT_ENABLE
Attempts:
3 left
💡 Hint
Common Mistakes
Enabling wrong bits
Confusing sample enable with sample and hold
3fill in blank
hard

Fix the error in the code to wait until ADC conversion is complete.

Embedded C
while (!(ADC_StatusRegister & [1])) {}
Drag options to blanks, or click blank then click option'
AADC_CONVERSION_COMPLETE_FLAG
BADC_SAMPLE_HOLD_FLAG
CADC_START_CONVERSION_FLAG
DADC_INTERRUPT_FLAG
Attempts:
3 left
💡 Hint
Common Mistakes
Waiting on wrong flag
Using sample hold flag instead of conversion complete
4fill in blank
hard

Complete the code to correctly read the ADC result and clear the conversion flag.

Embedded C
uint16_t result = ADC_ResultRegister;
ADC_StatusRegister &= ~[1];
Drag options to blanks, or click blank then click option'
BADC_CONVERSION_COMPLETE_FLAG
D0xFFFF
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to modify the result value
Not clearing the flag properly
5fill in blank
hard

Fill all three blanks to configure ADC for sample and hold with 10-bit resolution and start conversion.

Embedded C
ADC_ControlRegister = [1] | [2];
ADC_StartConversion([3]);
Drag options to blanks, or click blank then click option'
AADC_SAMPLE_HOLD_ENABLE
BADC_RESOLUTION_10BIT
CADC_CHANNEL_2
DADC_CHANNEL_0
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong resolution bits
Starting conversion on wrong channel