Concept Flow - Single channel ADC reading
Start ADC
Wait for ADC conversion complete?
No→Wait
Yes
Read ADC value
Use ADC value
End or Repeat
This flow shows starting the ADC, waiting for conversion, reading the value, and then using it.
ADC_Start(); while(!ADC_ConversionComplete()); int value = ADC_Read(); // Use value
| Step | Action | ADC Status | Conversion Complete? | ADC Value | Next Step |
|---|---|---|---|---|---|
| 1 | Call ADC_Start() | Started | No | N/A | Wait for conversion |
| 2 | Check ADC_ConversionComplete() | Started | No | N/A | Keep waiting |
| 3 | Check ADC_ConversionComplete() | Started | Yes | N/A | Read ADC value |
| 4 | Call ADC_Read() | Started | Yes | 523 | Use ADC value |
| 5 | Use ADC value | Started | Yes | 523 | End or Repeat |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | After Step 4 | Final |
|---|---|---|---|---|---|---|
| ADC Status | Idle | Started | Started | Started | Started | Started |
| Conversion Complete | False | False | False | True | True | True |
| ADC Value | N/A | N/A | N/A | N/A | 523 | 523 |
Single channel ADC reading: 1. Start ADC conversion 2. Wait until conversion complete flag is true 3. Read ADC value 4. Use the value for processing Always wait for conversion to finish before reading.
int adcValue = ADC_Read();
printf("ADC Value: %d\n", adcValue);ADC_Init();
int value = ADC_Read();
ADC_StartConversion();
printf("Value: %d", value);int adcValue = ADC_Read(); float voltage = ?;
Pass the test and this pattern moves unknown