ADC Module¶
Note
Features¶
Available ADCs¶
ADC1_14
: ADC1 Channel 14, found on connector X8ADC1_15
: ADC1 Channel 15, found on connector X8ADC1_16
: ADC1 Channel 16, found on connector X8ADC2_3
: ADC2 Channel 3, found on connector X8ADC3_8
: ADC3 Channel 8, found on connector X8Potentiometer
: Connected to Potentiometer on the left side of the board
Measuring a voltage¶
To measure the voltage applied to a pin, the following code can be used. Before being able to read the voltage value in, first a measurement needs to be started. After that, wait until the measurement is done.
Important
Make sure to only ever apply a voltage somewhere between 0.0V and 3.3V to the ADC pins. Higher or lower voltages can permanentally damage your board!
ADC_StartMeasurement(Potentiometer);
while (!ADC_IsReady(Potentiometer));
float32_t voltage;
if (R_SUCCESS(ADC_GetValue(Potentiometer, &voltage)) {
// Use voltage value
}
-
result_t ADC_StartMeasurement(ADC_Input_t input)¶
Starts conversion of one ADC input.
input ADC Input
- Returns
Status result
-
bool ADC_IsReady(ADC_Input_t input)¶
Checks if ADC conversion is done.
- Parameters
input – ADC Input
- Returns
Done
-
result_t ADC_GetValue(ADC_Input_t input, float32_t *result)¶
Gets the current ADC value.
Note
Blocks if conversion is not done yet
- Parameters
input – ADC Input
result – Pointer where result in volts is written to
- Returns
Status result