2023-08-13 02:22 AM
I am trying to use the AD converter on my Nucleo-F030R8 board. (Actually it works with the "HAL" functions, but I am trying to program on a lower level).
While debugging I am watching my struct ADC1 (Wich points at the ADC registers). I am trying to write:
ADC1->SMPR = 7; //(ADC_SMPR_SMP_0 | ADC_SMPR_SMP_1 | ADC_SMPR_SMP_2); but when I read the value of this register in debugging mode, it still says that the value is zero.
I have included: #include "stm32f030x8.h" in the header, but it still won't let me write to this register...
It seams to be working when I first run: MX_ADC_Init();, but if I comment it away it won't work.
Solved! Go to Solution.
2023-08-13 02:40 AM
ADC registers have various interlocks controlled by the "main" control bits, and this is not always well documented. \
In this case, SMPR is probably supposed to be written after you've enabled ADC clock in RCC and enabled ADC by ADEN, but did not start it by ADSTART.
JW
2023-08-13 02:40 AM
ADC registers have various interlocks controlled by the "main" control bits, and this is not always well documented. \
In this case, SMPR is probably supposed to be written after you've enabled ADC clock in RCC and enabled ADC by ADEN, but did not start it by ADSTART.
JW
2023-08-14 01:53 PM
Enabeling the ADC in the "APB peripheral clock enable register 2 (RCC_APB2ENR)" did the trick Thank you Jan. (y)