Question
STM32H7 ADC1 can not be enabled
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