STM32 ADC v.3 Error Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
alexblack
Posts: 276
Joined: Mon Sep 24, 2012 3:52 pm
Location: Donetsk
Been thanked: 32 times
Contact:

STM32 ADC v.3 Error  Topic is solved

Postby alexblack » Thu Apr 29, 2021 6:02 pm

Hi.
In current trunk and stable branch it seems an error in adc v.3 driver:
In function adc_lld_vreg_on used erorrnous macro ADC_CR_ADVREGEN while in function adc_lld_vreg_off used right macro ADC_CR_DEEPPWD.

Code: Select all

 .\os\hal\ports\STM32\LLD\ADCv3\hal_adc_lld.c
...
129 /**
130  * @brief   Enables the ADC voltage regulator.
131  *
132  * @param[in] adcp      pointer to the @p ADCDriver object
133  */
134 static void adc_lld_vreg_on(ADCDriver *adcp) {
135
136   adcp->adcm->CR = 0;   /* See RM.*/
137   adcp->adcm->CR = ADC_CR_ADVREGEN;
138 #if STM32_ADC_DUAL_MODE
139   adcp->adcs->CR = ADC_CR_ADVREGEN;
140 #endif
141   osalSysPolledDelayX(OSAL_US2RTC(STM32_HCLK, 20));
142 }
143
144 /**
145  * @brief   Disables the ADC voltage regulator.
146  *
147  * @param[in] adcp      pointer to the @p ADCDriver object
148  */
149 static void adc_lld_vreg_off(ADCDriver *adcp) {
150
151   adcp->adcm->CR = 0;   /* See RM.*/
152   adcp->adcm->CR = ADC_CR_DEEPPWD;
153 #if STM32_ADC_DUAL_MODE
154   adcp->adcs->CR = 0;
155   adcp->adcs->CR = ADC_CR_DEEPPWD;
156 #endif
157 }
...

The macro ADC_CR_ADVREGEN is defined in file "stm32f303xc.h" as

Code: Select all

...
1042 #define ADC_CR_ADVREGEN_Msk            (0x3U << ADC_CR_ADVREGEN_Pos)           /*!< 0x30000000 */
1043 #define ADC_CR_ADVREGEN                ADC_CR_ADVREGEN_Msk                     /*!< ADC voltage regulator enable */
1044 #define ADC_CR_ADVREGEN_0              (0x1U << ADC_CR_ADVREGEN_Pos)           /*!< 0x10000000 */
1045 #define ADC_CR_ADVREGEN_1              (0x2U << ADC_CR_ADVREGEN_Pos)           /*!< 0x20000000 */
...

but there must be used another macros but it is not work

Code: Select all

.\os\hal\ports\STM32\LLD\ADCv3\hal_adc_lld.c
79 #if !defined(ADC_CR_ADVREGEN)
80 #define ADC_CR_ADVREGEN         ADC_CR_ADVREGEN_0
81 #endif

Also this macro used in assertion code in function adc_lld_calibration.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: STM32 ADC v.3 Error

Postby Giovanni » Fri Aug 20, 2021 10:52 am

Hi,

Fixed as bug #1182.

A check would be appreciated.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 9 guests