cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G4 HAL does not support ADC_CHANNEL_0. Bug?

unterberg_rtb
Associate III

We are using the ADC on an STM32G4xx for a safety project. The safety manual requires us to read VSS or VDD for ADC diagnostics. STM32G4 has ADC channel 0 internally connected to VSSA, so we are trying to use HAL_ADC_ConfigChannel() to configure ADC_CHANNEL_0.

Unfortunately, HAL_ADC_ConfigChannel() asserts on IS_ADC_CHANNEL(hadc, sConfig->Channel) because IS_ADC_CHANNEL() does not check for ADC_CHANNEL_0. I would assume this is a bug in stm32g4xx_hal_adc_ex.h since all ADC instances in the G4 do support VSS as valid input channel (see reference manual section 21.4.4).

Can someone please look at this?

Regards, Norbert

1 ACCEPTED SOLUTION

Accepted Solutions
Imen.D
ST Employee

Hello @unterberg_rtb ,

First let me welcome you to the STM32 Community :) and thank you for having reported this issue.

Indeed, this is a confirmed issue in HAL ADC driver: ADC_CHANNEL_0 is listed, so it must be checked by macro IS_ADC_CHANNEL().

To do: In this macro, and add "ADC_CHANNEL_0".

#define IS_ADC_CHANNEL(__HANDLE__, __CHANNEL__)  (      ( ((__CHANNEL__) == ADC_CHANNEL_1)                || \
                                                          ((__CHANNEL__) == ADC_CHANNEL_2)                || \
                     ...

An internal ticket ID 159520 is submitted for correction.
(PS: ID 159520 is an internal tracking number and is not accessible or usable by customers).

Thanks

Imen

 

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

View solution in original post

1 REPLY 1
Imen.D
ST Employee

Hello @unterberg_rtb ,

First let me welcome you to the STM32 Community :) and thank you for having reported this issue.

Indeed, this is a confirmed issue in HAL ADC driver: ADC_CHANNEL_0 is listed, so it must be checked by macro IS_ADC_CHANNEL().

To do: In this macro, and add "ADC_CHANNEL_0".

#define IS_ADC_CHANNEL(__HANDLE__, __CHANNEL__)  (      ( ((__CHANNEL__) == ADC_CHANNEL_1)                || \
                                                          ((__CHANNEL__) == ADC_CHANNEL_2)                || \
                     ...

An internal ticket ID 159520 is submitted for correction.
(PS: ID 159520 is an internal tracking number and is not accessible or usable by customers).

Thanks

Imen

 

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen