2024-10-25 04:21 PM - last edited on 2024-10-26 03:49 AM by SofLit
Hi,
I am trying to set-up the ADC3 for STM32H7 but the HAL_ADC_Init() fails ?
After debugging, I see that the function LL_ADC_IsInternalRegulatorEnabled() fails in HAL_ADC_Init(). I also see that DEEPPWD is 0 on reset but the datasheet say that it should be 1 on reset. Why is this so ?
regards,
Daan
Solved! Go to Solution.
2024-10-28 03:36 AM
Hello,
I didn't reproduce the behavior on NUCLEO-H743 board.
HAL_ADC_Init(&hadc3) call passed without any error.
Need to check you HW.
2024-10-26 03:48 AM
Hello,
You need always to provide the MCU part number in your post + share your code.
Please review tips on posting.
Thank you.
2024-10-28 01:00 AM - last edited on 2024-10-28 02:17 AM by SofLit
Hi,
MCU is STM32H743.
The code is CubeMx generated.
Clock Config is as given below:
static void MX_ADC3_Init(void)
{
/* USER CODE BEGIN ADC3_Init 0 */
/* USER CODE END ADC3_Init 0 */
ADC_ChannelConfTypeDef sConfig = {0};
/* USER CODE BEGIN ADC3_Init 1 */
/* USER CODE END ADC3_Init 1 */
/** Common config
*/
hadc3.Instance = ADC3;
hadc3.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
hadc3.Init.ScanConvMode = ADC_SCAN_DISABLE;
hadc3.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
hadc3.Init.LowPowerAutoWait = DISABLE;
hadc3.Init.ContinuousConvMode = DISABLE;
hadc3.Init.NbrOfConversion = 1;
hadc3.Init.DiscontinuousConvMode = DISABLE;
hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc3.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc3.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR;
hadc3.Init.Overrun = ADC_OVR_DATA_PRESERVED;
hadc3.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;
hadc3.Init.OversamplingMode = DISABLE;
hadc3.Init.Oversampling.Ratio = 1;
hadc3.Init.Resolution = ADC_RESOLUTION_16B;
if (HAL_ADC_Init(&hadc3) != HAL_OK)
{
}
static void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Supply configuration update enable
*/
(void)HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
/** Configure the main internal regulator output voltage
*/
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
/* NOTE: The Oscillator Type value was previously modified by the different dev, */
/* not sure about any particular reason assocuated with it, */
/* tried to do the same configuration into the CubeMX, but no luck. */
/* Need to make sure to put this change manually once code is re-generated! */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
RCC_OscInitStruct.LSIState = RCC_LSE_BYPASS;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 1;
RCC_OscInitStruct.PLL.PLLN = 100;
RCC_OscInitStruct.PLL.PLLP = 2;
RCC_OscInitStruct.PLL.PLLQ = 100;
RCC_OscInitStruct.PLL.PLLR = 2;
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3;
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
RCC_OscInitStruct.PLL.PLLFRACN = 0;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2
|RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
}
}
2024-10-28 02:15 AM
Could you please share your ioc file?
2024-10-28 03:19 AM - edited 2024-10-28 04:01 AM
Hi @SofLit ,
ioc file attached.
2024-10-28 03:36 AM
Hello,
I didn't reproduce the behavior on NUCLEO-H743 board.
HAL_ADC_Init(&hadc3) call passed without any error.
Need to check you HW.
2024-10-28 03:40 AM - edited 2024-10-28 04:00 AM
Thanks for your prompt response.
2024-10-28 04:04 AM - edited 2024-10-28 04:57 AM
Hello,
@Daan1 wrote:
Thanks for your prompt response.
Sorry, I didn't understand, did I answer your question?