Questions and discussions about the software that runs on the TD RF module itself.
ramon2015
 
Posts: 51
Joined: Mon Jul 06, 2015 4:06 pm

ADC pin definition

by ramon2015 Sat Sep 03, 2016 6:19 pm

I am having problems at converting the voltage at ADC0 pin.

I have 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.
Return to Firmware

Who is online

Users browsing this forum: No registered users and 24 guests