Skip to main content
Visitor II
April 11, 2024
Question

[STM32H5] ADC clock configuration for different ADCs

  • April 11, 2024
  • 3 replies
  • 1501 views

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

    This topic has been closed for replies.

    3 replies

    Technical Moderator
    April 11, 2024

    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.

    AnushaAuthor
    Visitor II
    April 11, 2024

    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??

     

    Technical Moderator
    April 12, 2024

    Hello,

    I think it's linked to this constraint on ADC clocks (from RM0481):

    SofLit_0-1712938602619.png

    So you can't set different prescalers for different ADCs. 

     

     

    Super User
    April 12, 2024

    Hi,

    see from rm:  clock/divider -> serving both ADC analog blocks

    AScha3_0-1712939478134.png