cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 ADC1 can not be enabled

Handzic.Dirk
Associate III
Posted on May 11, 2018 at 09:19

Hi,

I am not able to start the ADC using the the HAL:

        hadc1.Instance = ADC1;

        hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV4;

        hadc1.Init.Resolution = ADC_RESOLUTION_16B;

        hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;

        hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;

        hadc1.Init.LowPowerAutoWait = DISABLE;

        hadc1.Init.ContinuousConvMode = ENABLE;

        hadc1.Init.NbrOfConversion = 1;

        hadc1.Init.DiscontinuousConvMode = DISABLE;

        hadc1.Init.NbrOfDiscConversion = 1;

        hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;

        hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;

        hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR;

        hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;

        hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;

        hadc1.Init.BoostMode = DISABLE;

        hadc1.Init.OversamplingMode = DISABLE;

        if(HAL_ADC_Init(&hadc1) != HAL_OK){

            Error_Handler();

        }  

        sConfig.Channel = ADC_CHANNEL_6;

        sConfig.Rank = ADC_REGULAR_RANK_1;

        sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;

        sConfig.SingleDiff = ADC_SINGLE_ENDED;

        sConfig.OffsetNumber = ADC_OFFSET_NONE;

        sConfig.Offset = 0;

        if(HAL_ADC_ConfigChannel(&hadc1,&sConfig) != HAL_OK){

            Error_Handler();

        }  

        if(HAL_ADC_Start(&hadc1) != HAL_OK){

            Error_Handler();

        } 

The ADC_ISR_ARDY bit is not set and the ADC_Enable function will return HAL_ERROR. My first thought has been the clock source which was PLL2P (not working for SPI1) and I changed it to PLL3R but that did not solve the problem this time.

Any suggestions?

Regards

Dirk

#stm32h7-adc
3 REPLIES 3
Handzic.Dirk
Associate III
Posted on May 11, 2018 at 11:05

Something seems to be tricky with RCC->PLLCFGR it seems that DIVP2EN and DIVR3EN can not be set to '1'. As a result any peripheral using these clock sources will NOT work even though peripheral registers can be written and change values which for older families STM32F1 and STM32F4 used to be an indication of clock problems if register values would not change.

Anyhow selecting PER_CK for ADC seems to be the only working solution to be able to run the ADC:

Regards

Dirk

CME
Associate II

Hello,

I think I have the same questions in ADC1, and the ADC Initial function was blocked in the Verification ADC voltage regulator.

Maybe is the problem of clocking, but I was using the code of example provided by official and it still fails

I will try the PER_CK.

https://community.st.com/s/profile/0050X0000088ndYQAQ

CME
Associate II

Hello again,

I checked my code, I'm indeed using the PER_CK:

__HAL_RCC_ADC_CONFIG(RCC_ADCCLKSOURCE_CLKP);

but nothing changed.

Would you please attach you code for me?

or, do you have any idea about this?

Thank!

CME