Closed FRASTM closed 2 years ago
Could it be a mistmatch between channel and index in the adc_stm32_teardown_channels() function call : Suggested correction:
diff --git a/drivers/adc/adc_stm32.c b/drivers/adc/adc_stm32.c
index 2015601b2a..69541a392c 100644
--- a/drivers/adc/adc_stm32.c
+++ b/drivers/adc/adc_stm32.c
@@ -901,7 +901,7 @@ static int start_read(const struct device *dev,
err = adc_context_wait_for_completion(&data->ctx);
- adc_stm32_teardown_channels(dev, index);
+ adc_stm32_teardown_channels(dev, channel);
return err;
}
Not sure what could be the cause yet, but currently the adc_stm32_teardown_channels
is getting the same arg as the adc_stm32_setup_channels
since two of them are similar
On both stm32wb55 and stm32L5x , the VREFINT channel is on the channel 0 of the ADC1/2 During the adc_stm32_teardown_channels() since the adc has config->has_vref_channel true, the __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_VREFINT) gives 0 which corresponds to the ADC_1ST_CHANNEL_ID of the sequence.
One possible WA for that test execution is to remove the has-vref-channel
property (with boards/overlay file)
&adc1 {
/delete-property/ has-vref-channel;
};
Another, for this particular test purpose is to set ADC_1ST_CHANNEL_ID = 1 for stm32wb55 and stm32l5 platforms.
diff --git a/tests/drivers/adc/adc_api/src/test_adc.c b/tests/drivers/adc/adc_api/src/test_adc.c
index f1e05c5ab5..4c16691169 100644
--- a/tests/drivers/adc/adc_api/src/test_adc.c
+++ b/tests/drivers/adc/adc_api/src/test_adc.c
@@ -214,8 +214,12 @@
#define ADC_GAIN ADC_GAIN_1
#define ADC_REFERENCE ADC_REF_INTERNAL
#define ADC_ACQUISITION_TIME ADC_ACQ_TIME_DEFAULT
+#if defined(CONFIG_BOARD_NUCLEO_WB55RG) || defined(CONFIG_BOARD_STM32L562E_DK)
+/* channel 0 is for VREFINT internal channel */
+#define ADC_1ST_CHANNEL_ID 1
+#else
#define ADC_1ST_CHANNEL_ID 0
+#endif /* CONFIG_BOARD_NUCLEO_WB55RG or CONFIG_BOARD_STM32L562E_DK */
#elif defined(CONFIG_BOARD_NUCLEO_F302R8) || \
defined(CONFIG_BOARD_NUCLEO_G474RE) || \
defined(CONFIG_BOARD_NUCLEO_L412RB_P)
However, the adc_stm32_teardown_channels when the channel ID is 0 --> VREFINT is not enabling (adc_stm32_enable) correctly this channel because it waits endlessly for LL_ADC_IsActiveFlag_ADRDY
Describe the bug tests/drivers/adc/adc_api test fails when running on
Test execution blocking in the first sequence _test_adc_asynchronouscall
Please also mention any information which could help others to understand the problem you're facing:
To Reproduce Steps to reproduce the behavior:
Expected behavior
Logs and console output
Environment (please complete the following information):
Additional context Add any other context that could be relevant to your issue, such as pin setting, target configuration, ...