cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to write to register (example ADC1->SMPR = 7)

RBakk.2
Associate

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

2 REPLIES 2

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

Enabeling the ADC in the "APB peripheral clock enable register 2 (RCC_APB2ENR)" did the trick Thank you Jan. (y)