C. ADCON0 is overwritten before turning on ADC, losing previous bits
D. The loop runs one time too many
Solution
Step 1: Check ADCON0 assignment
ADCON0 is assigned with (i << 2), which clears other bits including ADC enable.
Step 2: Understand bitwise OR usage
Turning on ADC with |= 0x01 works, but previous bits are lost due to overwrite.
Final Answer:
ADCON0 is overwritten before turning on ADC, losing previous bits -> Option C
Quick Check:
Overwriting ADCON0 clears important bits [OK]
Hint: Use |= to set bits, not = to overwrite [OK]
Common Mistakes:
Ignoring that ADCON0 bits get reset
Thinking start bit is not set
Miscounting loop iterations
Misunderstanding ADC result storage
5.
You want to scan 4 analog sensors using a microcontroller ADC that supports hardware scanning. Which approach best improves efficiency?
// Option 1: Manually switch channels in software loop
// Option 2: Enable hardware scan mode and read results from buffer
// Option 3: Use single channel repeatedly
// Option 4: Use digital inputs instead
hard
A. Use hardware scan mode and read results from buffer
B. Manually switch channels in software loop
C. Use single channel repeatedly with delays
D. Use digital inputs instead of ADC
Solution
Step 1: Compare manual vs hardware scanning
Manual switching requires CPU cycles and delays; hardware scan automates channel switching.
Step 2: Identify efficiency gain
Hardware scan mode reads multiple channels automatically, storing results in buffer for quick access.
Step 3: Evaluate other options
Using single channel repeatedly or digital inputs does not meet multi-channel analog reading needs efficiently.
Final Answer:
Use hardware scan mode and read results from buffer -> Option A