STM32F0XX ADC Configuration Code Problem?

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
carldong
Posts: 62
Joined: Wed Oct 15, 2014 6:08 pm
Has thanked: 1 time
Been thanked: 1 time

STM32F0XX ADC Configuration Code Problem?

Post by carldong »

Hello,

As I read through the code in adc_llc.c, I found the following snippet:

Code: Select all

#if STM32_ADCSW == STM32_ADCSW_HSI14
      /* Clock from HSI14, no need for jitter removal.*/
      ADC1->CFGR2 = 0x00001000;
#else
#if STM32_ADCPRE == STM32_ADCPRE_DIV2
      ADC1->CFGR2 = 0x00001000 | ADC_CFGR2_JITOFFDIV2;
#else
      ADC1->CFGR2 = 0x00001000 | ADC_CFGR2_JITOFFDIV4;
#endif

However, as I read the documentation from ST, the ADCSW bit in RCC->CFGR3 is obselete:
Obsolete setting. To be kept at reset value, connecting the HSI14 clock to the ADC
asynchronous clock input. Proper ADC clock selection is done inside the ADC_CFGR2 (refer
to Section 12.11.5: ADC configuration register 2 (ADC_CFGR2) on page 198).

Another problem is that, I don't understand why bit 12 is set (the 0x00001000). The document says:
Bits 29:0 Reserved, must be kept at reset value.

Could someone explain these? Thanks.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F0XX ADC Configuration Code Problem?

Post by Giovanni »

In a previous version of the RM the reset value was documented as 0x00001000, this is the reason you see that in the code. Probably the bit is not writable and it makes no difference. Everything else is fine, just keep STM32_ADCSW = STM32_ADCSW_HSI14.

Giovanni
carldong
Posts: 62
Joined: Wed Oct 15, 2014 6:08 pm
Has thanked: 1 time
Been thanked: 1 time

Re: STM32F0XX ADC Configuration Code Problem?

Post by carldong »

OK, I get it.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F0XX ADC Configuration Code Problem?

Post by Giovanni »

Hi,

That 0x00001000 constant has been removed from the code.

Giovanni
Post Reply