I initially noticed that if I enable the ADC (even without using it at all) via setting HAL_USE_ADC to TRUE in halconf.h that my system would hang. After stepping through the issue I discovered that in adc_lld_init (in os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.c) my processor is waiting forever for the ADC calibration routing to finish running.
Code: Select all
diff --git a/os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.c b/os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.c
index 12620003c..30c990ed7 100644
--- a/os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.c
+++ b/os/hal/ports/STM32/LLD/ADCv1/hal_adc_lld.c
@@ -170,6 +170,7 @@ void adc_lld_init(void) {
osalDbgAssert(ADC1->CR == 0, "invalid register state");
ADC1->CR |= ADC_CR_ADCAL;
osalDbgAssert(ADC1->CR != 0, "invalid register state");
+ // The below while loop hangs forever
while (ADC1->CR & ADC_CR_ADCAL)
;
rccDisableADC1();
I've attached a simple blinky program that will hang if you change HAL_USE_ADC to TRUE.
I'm currently developing with:
Hardware: NUCLEO-G071RB
Toolchain: 5.4.1 20160919
ChibiOS: master 4c56ee69c6918402d483e759b4d443c012ab5486
OpenOCD: Custom build to enable STM32G07xx (have also tested STM32 ST-LINK Utility on Windows)