2024-04-10 11:47 PM - last edited on 2024-04-12 09:20 AM by SofLit
Hi,
I am using both ADC1 and ADC2 for my project. I want both the ADCs to be configured with different Prescalar .
But by doing so I am observing ADC2 working with the ADC1 Prescalar. Why am I facing this issue?
Is it possible to configure both the ADCs with different Prescalar?
Thankyou
2024-04-11 01:02 AM
Hello,
You need to provide more details:
The exact MCU part number.
A screenshot of the issue or the code or what else showing it.
2024-04-11 02:18 AM
Hi,
I am using STM32H563VIT6 board.
ADC configuration used for ADC1 :
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV8;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV;
hadc1.Init.LowPowerAutoWait = DISABLE;
hadc1.Init.ContinuousConvMode = ENABLE;
hadc1.Init.NbrOfConversion = 6;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc1.Init.DMAContinuousRequests = DISABLE;
hadc1.Init.SamplingMode = ADC_SAMPLING_MODE_NORMAL;
hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
hadc1.Init.OversamplingMode = DISABLE;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
Error_Handler();
Configuration used for ADC2:
hadc2.Instance = ADC2;
hadc2.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV256;
hadc2.Init.Resolution = ADC_RESOLUTION_12B;
hadc2.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc2.Init.ScanConvMode = ADC_SCAN_ENABLE;
hadc2.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
hadc2.Init.LowPowerAutoWait = DISABLE;
hadc2.Init.ContinuousConvMode = ENABLE;
hadc2.Init.NbrOfConversion = 2;
hadc2.Init.DiscontinuousConvMode = DISABLE;
hadc2.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc2.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc2.Init.DMAContinuousRequests = ENABLE;
hadc2.Init.SamplingMode = ADC_SAMPLING_MODE_NORMAL;
hadc2.Init.Overrun = ADC_OVR_DATA_PRESERVED;
hadc2.Init.OversamplingMode = DISABLE;
if (HAL_ADC_Init(&hadc2) != HAL_OK)
Error_Handler();
The ADC clock selected is HCLK which is 240Mhz.
Therefore for for ADC1 clock should be (240/8)MHz.
for ADC2 it should be (240/256)MHz.
Both the ADC is configured in DMA mode hence if I do a timing measurement of ADC data collection
both ADC1 and ADC2 is configured at (240/8)Mhz.
WHY???
Can 2 ADC be configured with different prescalar??
2024-04-12 09:18 AM - edited 2024-04-12 09:26 AM
Hello,
I think it's linked to this constraint on ADC clocks (from RM0481):
So you can't set different prescalers for different ADCs.
2024-04-12 09:31 AM
Hi,
see from rm: clock/divider -> serving both ADC analog blocks