Created
November 5, 2018 23:19
-
-
Save sidprice/68d41b99c2b755409277545b600a363f to your computer and use it in GitHub Desktop.
ADC issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define WDBP_BATTERY_INPUT 0 // ADC Channel for battery input | |
#define WDBP_TARGET_VOLTAGE_INPUT 8 // ADC Chanmel for target voltage | |
#define WDBP_ADC_BATTERY 0 | |
#define WDBP_ADC_TARGET 1 | |
static uint32_t inputVoltages[2] = { 0 }; | |
static uint8_t adcChannels[2] = { WDBP_BATTERY_INPUT , WDBP_TARGET_VOLTAGE_INPUT }; | |
//////////////////////////////////////////////////////////////////////////////////////////////////// | |
/// <summary> Read all the ADC channels used by WDBP</summary> | |
/// | |
/// <remarks> Sid Price, 11/4/2018.</remarks> | |
//////////////////////////////////////////////////////////////////////////////////////////////////// | |
static uint32_t whichChannel = WDBP_ADC_BATTERY; | |
void platform_adc_read (void) | |
{ | |
PROBE_PIN; | |
adc_set_regular_sequence (ADC1, 1, &(adcChannels[whichChannel])); | |
adc_start_conversion_regular (ADC1); | |
/* Wait for end of conversion. */ | |
while (!adc_eoc (ADC1)) | |
; | |
inputVoltages[whichChannel] = adc_read_regular (ADC1); | |
if (whichChannel == WDBP_ADC_BATTERY) | |
{ | |
whichChannel = WDBP_ADC_TARGET; | |
} | |
else | |
{ | |
whichChannel = WDBP_ADC_BATTERY; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment