Skip to content

Commit b7be4ee

Browse files
committed
stm32/machine_adc: Enable ADC re-read errata handling for STM32WB55.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
1 parent 5eee5a6 commit b7be4ee

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

ports/stm32/machine_adc.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,14 @@ static void adc_config_channel(ADC_TypeDef *adc, uint32_t channel, uint32_t samp
445445

446446
static uint32_t adc_read_channel(ADC_TypeDef *adc) {
447447
uint32_t value;
448-
#if defined(STM32G4)
449-
// For STM32G4 there is errata 2.7.7, "Wrong ADC result if conversion done late after
450-
// calibration or previous conversion". According to the errata, this can be avoided
451-
// by performing two consecutive ADC conversions and keeping the second result.
452-
for (uint8_t i = 0; i < 2; i++)
448+
#if defined(STM32G4) || defined(STM32WB)
449+
// For STM32G4 errata 2.7.7 / STM32WB errata 2.7.1:
450+
// "Wrong ADC result if conversion done late after calibration or previous conversion"
451+
// states an incorrect reading is returned if more than 1ms has elapsed since the last
452+
// reading or calibration. According to the errata, this can be avoided by performing
453+
// two consecutive ADC conversions and keeping the second result.
454+
// Note: On STM32WB55 @ 64Mhz each ADC read takes ~ 3us.
455+
for (int8_t i = 0; i < 2; i++)
453456
#endif
454457
{
455458
#if ADC_V2

0 commit comments

Comments
 (0)