Closed wouter-palmsens closed 10 months ago
The macro IS_ADC_CALFACT is currently defined (see here) as:
IS_ADC_CALFACT
#define IS_ADC_CALFACT(__CALIBRATION_FACTOR__) ((__CALIBRATION_FACTOR__) <= (0x7FU))
This macro is used to check the parameters of HAL_ADCEx_Calibration_SetValue (see here):
HAL_ADCEx_Calibration_SetValue
assert_param(IS_ADC_CALFACT(CalibrationFactor));
Consequently, when USE_FULL_ASSERT is enabled in the HAL, the assertion is violated when using a calibration factor with a value larger than 127.
USE_FULL_ASSERT
However, the calibration factor is 11 bits, so I think the check should be <= 0x7FFU.
<= 0x7FFU
Patch
The corrected code should be:
/** * @brief Calibration factor size verification (11 bits maximum). * @param __CALIBRATION_FACTOR__ Calibration factor value. * @retval SET (__CALIBRATION_FACTOR__ is within the authorized size) or RESET (__CALIBRATION_FACTOR__ is too large) */ #define IS_ADC_CALFACT(__CALIBRATION_FACTOR__) ((__CALIBRATION_FACTOR__) <= 0x7FFU)
Note that the documentation of HAL_ADCEx_Calibration_SetValue also mentions the 7 bits maximum instead of 11 bits maximum:
* @param CalibrationFactor Calibration factor (coded on 7 bits maximum)
should be:
* @param CalibrationFactor Calibration factor (coded on 11 bits maximum)
ST Internal Reference: 157901
Fixed in 6e22b5b
The macro
IS_ADC_CALFACT
is currently defined (see here) as:This macro is used to check the parameters of
HAL_ADCEx_Calibration_SetValue
(see here):Consequently, when
USE_FULL_ASSERT
is enabled in the HAL, the assertion is violated when using a calibration factor with a value larger than 127.However, the calibration factor is 11 bits, so I think the check should be
<= 0x7FFU
.Patch
The corrected code should be:
Note that the documentation of
HAL_ADCEx_Calibration_SetValue
also mentions the 7 bits maximum instead of 11 bits maximum:should be: