Skip to main content
CBrom.1
Associate II
April 7, 2021
Question

Incorrect values by ADC on STM32H750

  • April 7, 2021
  • 2 replies
  • 1354 views

Hello!

A simple setup to run the ADC1 in continuous conversion mode runs as expected, but the measured values are incorrect as inspected via the debugger console. When connecting the ADC1 input pin to GND or 3.3V volts the measured value doesn't change as expected but always fluctuates around the decimal value of roughly ~14000.

The hardware I'm using is a custom discovery board from China according to the schematic:

https://github.com/mcauser/MCUDEV_DEVEBOX_H7XX_M/blob/master/docs/STM32H7XX_M_schematics.pdf

To discard issues with the hardware I verified the connectivity with a multimeter.

The problem persists when using other ADC channels/ input pins.

The code I used is:

int main(void)
{
#define ANALOG_IN 3
#define ADC_PA0_KANAL 16 // ADC1_INP16
 
 RCC->AHB4ENR |= RCC_AHB4ENR_GPIOAEN; // PortA active
 RCC->AHB1ENR |= RCC_AHB1ENR_ADC12EN; // dto. ADC_12
 RCC->D3CCIPR |= RCC_D3CCIPR_ADCSEL_1; // per_clk ADC_12 enable
 GPIOA->MODER |= ANALOG_IN; // PA0 analog IN
 ADC12_COMMON->CCR = ADC_CCR_PRESC_3; // prescaler /32
 ADC1->CR = ADC_CR_BOOST | ADC_CR_ADVREGEN ;
 
 ADC1->SQR1 = ADC_PA0_KANAL << ADC_SQR1_SQ1_Pos; // input selection
 
 ADC1->CFGR = (0b000<<ADC_CFGR_RES_Pos) | // 16 Bit
			ADC_CFGR_JQDIS |
			ADC_CFGR_OVRMOD |
			ADC_CFGR_CONT; // continous conversion
 
 ADC1->CR |= ADC_CR_ADEN |
			ADC_CR_ADSTART;
 
 uint32_t tmp;
 while (1)
 {
	 tmp = ADC1->DR;
 }
}

What am I missing here? Is there a special setting to be considered because ADC1 and ADC2 are tightly couple?

This topic has been closed for replies.

2 replies

CBrom.1
CBrom.1Author
Associate II
April 13, 2021

So in the end I feel a little embarrassed about my question because in hindsight it seems rather clear. Anyways, in case someone got stuck at the same point and finds this post: the solution is to configure the ADCs channel preselection register PCSEL. For the example above one just has to add

LL_ADC_SetChannelPreSelection(ADC1, LL_ADC_CHANNEL_16);

or

ADC1->PCSEL |= (1UL << ADC_PA0_KANAL);

to the ADC configuration.

AMakw.1
Associate
July 1, 2022

Hi

@CBrom.1​ 

You got any solution for ADC issue.

I am facing same result conversion issue.

1) connecting 0V to channel 14 -> ADC result was half value of 16bit resolution (32767)

2) connecting 3.3v to channel 14 -> ADC result was full value of 16bit resolution (65535)

Setup:

CubeIDE : V1.10.0 Latest One

MCU : STM32H750VBT6

ADC : 2

Channel : 14

Method : Pulling Conversion

if you have any solution, could you please help to resolve it .

I am not to sure what to look for, i am struggling to solve it from past few days.

Thanks & Regards,

Ashvin Makwana