cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 ADC3 setup fails

Daan1
Associate II

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 ?

Daan1_0-1729897920043.png

regards,
Daan

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hello,

I didn't reproduce the behavior on NUCLEO-H743 board. 

HAL_ADC_Init(&hadc3) call passed without any error.

SofLit_0-1730111747824.png

Need to check you HW.

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

7 REPLIES 7
SofLit
ST Employee

Hello,

You need always to provide the MCU part number in your post + share your code.

Please review tips on posting.

Thank you.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

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)

  {


  }

}

Could you please share your ioc file?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Hi @SofLit ,

ioc file attached. 

Hello,

I didn't reproduce the behavior on NUCLEO-H743 board. 

HAL_ADC_Init(&hadc3) call passed without any error.

SofLit_0-1730111747824.png

Need to check you HW.

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Thanks for your prompt response.

Hello, 


@Daan1 wrote:

Thanks for your prompt response.


Sorry, I didn't understand, did I answer your question?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.