Page 1 of 1

ADC pin definition

Posted: Wed Aug 10, 2016 12:06 pm
by ramon2015
I am having problems at converting the voltage at ADC0 pin.

I hace defined the pin as follows:

// ANALOG INPUT as digital input ??
GPIO_PinModeSet(BAT_ADC_PORT, BAT_ADC_BIT, gpioModeInputPullFilter, 0);

and then,

ADC_SingleInput_TypeDef adc_channel = adcSingleInpCh0;
ADC_Ref_TypeDef volt_ref_adc = adcRef2V5;
uint32_t adc_val=0;

// get sample
adc_val = TD_MEASURE_SingleVoltage ( adc_channel, volt_ref_adc );

// bin to Volts (in mV)
//adc_val = volt_ref_val * adc_val / 4096; // 12 bit resolution (LSB_voltage * ADC_code)

Anything wrong?

The converted value does not match the real one.

Regards, Ramon.

Re: ADC pin definition

Posted: Wed Aug 10, 2016 12:09 pm
by ramon2015
sorry, I left the comment by mistake

// bin to Volts (in mV)
adc_val = volt_ref_val * adc_val / 4096; // 12 bit resolution (LSB_voltage * ADC_code)