cancel
Showing results for 
Search instead for 
Did you mean: 

G4 library bug

TMark.14
Associate III

Stm32g4xx_hal_adc.c line 644 adc_multi_skave macro returns null if adc3 is a parameter to the macro, when it should return pointer to adc4.

8 REPLIES 8
TMark.14
Associate III

Stcubeide 1.6.0

Mcu - Stm32g491re

TMark.14
Associate III

Ok I see there is no adc4 on stm32g491re, but why cube ide generates a multimodeconfigchannel function call?

TDK
Guru

The STM32G491RE has 3 ADCs per the datasheet and per the CMSIS include file. ADC4 doesn't exist on this chip.

If you feel a post has answered your question, please click "Accept as Solution".
TMark.14
Associate III

Correct, but why cubeide generates the multimodeconfigchannel function call for mx_adc3_init? It will get stuck in error handler every time.

TDK
Guru

I see no such call on a new project. Consider including your IOC file.

/**
  * @brief ADC3 Initialization Function
  * @param None
  * @retval None
  */
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_SYNC_PCLK_DIV2;
  hadc3.Init.Resolution = ADC_RESOLUTION_12B;
  hadc3.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  hadc3.Init.GainCompensation = 0;
  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.DMAContinuousRequests = DISABLE;
  hadc3.Init.Overrun = ADC_OVR_DATA_PRESERVED;
  hadc3.Init.OversamplingMode = DISABLE;
  if (HAL_ADC_Init(&hadc3) != HAL_OK)
  {
    Error_Handler();
  }
  /** Configure Regular Channel
  */
  sConfig.Channel = ADC_CHANNEL_1;
  sConfig.Rank = ADC_REGULAR_RANK_1;
  sConfig.SamplingTime = ADC_SAMPLETIME_2CYCLES_5;
  sConfig.SingleDiff = ADC_SINGLE_ENDED;
  sConfig.OffsetNumber = ADC_OFFSET_NONE;
  sConfig.Offset = 0;
  if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN ADC3_Init 2 */
 
  /* USER CODE END ADC3_Init 2 */
 
}

If you feel a post has answered your question, please click "Accept as Solution".
TMark.14
Associate III

Here is ioc file.

In MX_ADC3_Init() function there is a following code:

multimode.Mode = ADC_MODE_INDEPENDENT;

 if (HAL_ADCEx_MultiModeConfigChannel(&hadc3, &multimode) != HAL_OK)

 {

  Error_Handler();

 }

The program always gets to Error_Handler().

Please confirm that the code you generate from the ioc file also generates the same problem or not.

TDK
Guru

Your IOC generates the problematic code. However, you are not on the latest package version. After I migrate the IOC to the latest version and generate code, the problem is no longer there.

If you feel a post has answered your question, please click "Accept as Solution".
TMark.14
Associate III

What exactly can I do to generate better code? Do you think it will require updating Cube IDE?

  I am asking because I cannot install software on the computer without headache from IT Dep.