2021-11-09 12:29 PM
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.
2021-11-09 12:31 PM
Stcubeide 1.6.0
Mcu - Stm32g491re
2021-11-09 12:46 PM
Ok I see there is no adc4 on stm32g491re, but why cube ide generates a multimodeconfigchannel function call?
2021-11-09 12:56 PM
The STM32G491RE has 3 ADCs per the datasheet and per the CMSIS include file. ADC4 doesn't exist on this chip.
2021-11-09 01:36 PM
Correct, but why cubeide generates the multimodeconfigchannel function call for mx_adc3_init? It will get stuck in error handler every time.
2021-11-09 02:50 PM
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 */
}
2021-11-10 06:25 AM
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.
2021-11-10 06:36 AM
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.
2021-11-10 07:47 AM
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.