How to use multiple ADC channels on STM32U575? I have always TIMEOUT error EDIT : Same error with the example "ADC_DifferentialMode"
Hi,
I would like to use ADC1_IN5, ADC1_IN6 and ADC1_IN7 on my STM32U575. To init ADC1 I have:
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
hadc1.Init.Resolution = ADC_RESOLUTION_8B;
hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
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.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc1.Init.DMAContinuousRequests = DISABLE;
hadc1.Init.TriggerFrequencyMode = ADC_TRIGGER_FREQ_HIGH;
hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;
hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR;
hadc1.Init.OversamplingMode = DISABLE;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
Error_Handler();
}After that, to have data for each channel I do this code (I only change sConfig.Channel) :
HAL_StatusTypeDef err;
sConfig.Channel = ADC_CHANNEL_5;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_5CYCLE;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;
sConfig.OffsetRightShift = DISABLE;
sConfig.OffsetSignedSaturation = DISABLE;
HAL_ADC_ConfigChannel(&hadc1, &sConfig);
HAL_ADC_Start(&hadc1);
if( (err = HAL_ADC_PollForConversion(&hadc1, 10)) == HAL_OK) {
*data = HAL_ADC_GetValue(&hadc1);
} else {
// nothing to do
}
HAL_ADC_Stop(&hadc1);But err is still HAL_TIMEOUT.
I used this method on a STM32L476 and it worked, so I don't understand why I have HAL_TIMEOUT with STM32U575.
EDIT : I have tested the example "ADC_DifferentialMode" and I have a TIMEOUT error in HAL_ADC_PollForConversion, when I place a breakpoint after the call of HAL_ADC_GetValue (in the while).
Thanks in advance
