Skip to main content
Visitor II
April 10, 2024
Question

ADC Sample Time for Differential Channels Incorrectly Initialized when using HAL drivers

  • April 10, 2024
  • 1 reply
  • 624 views

I'm using the HAL drivers to configure ADC1 Channel 3 as Differential and Channel 4 as Single Ended.

According to the reference manual (Figure 143) when ADC1 Channel 3 is differential, it is Channel 7 that becomes unavailable as it is used as INN3.  This is further supported by the STM32CubeIDE which grays out Channel 7 when Channel 3 is made differential.

However, when the sample times registers are updated for the differential channels it is SMPR1 (SMP3 and SMP4) that are updated.

When Channel 4 sample time is configured SMPR1 (SMP4) gets overwritten.

 

In stm32h7xx_hal_adc.c (HAL_ADC_ConfigChannel) the sample times are updated for the channel:

LL_ADC_SetChannelSamplingTime(hadc->Instance, sConfig->Channel, sConfig->SamplingTime);

And if the channel is differential sets the sample time of the associated channel:

 LL_ADC_SetChannelSamplingTime(hadc->Instance,
(uint32_t)(__LL_ADC_DECIMAL_NB_TO_CHANNEL((__LL_ADC_CHANNEL_TO_DECIMAL_NB((uint32_t)sConfig->Channel) + 1UL) & 0x1FUL)),
sConfig->SamplingTime);

Does this second channel's sampling time need to be set and should it be Channel 7 in this example?

If channels 10, 11, 12, 13, 16 or 18 are configured as differential it is the next channel that is used as the INN.

    This topic has been closed for replies.

    1 reply

    ST Employee
    April 11, 2024

    Hi @NBrick67 

     

    This post has been escalated to the ST Online Support Team for additional assistance.  We'll contact you directly.

     

    Regards,

    Billy