Page 1 of 1

STM32F302x8 ADC bug (3.0.x)

Posted: Sat Nov 07, 2015 1:55 am
by austin_boulderes
This describes a bug found in chibios 3.0 (though it's still present in the master branch of the git repository).

The STM32F302x8 (as opposed to the 302xc) does not have an ADC2, and the ADC1_2_COMMON structure (defined in the CMSIS file) is therefore name ADC1_COMMON. This causes an error in adc_lld.c, at the line:

Code: Select all

  ADCD1.adcc = ADC1_2_COMMON;


There are also similar errors in stm32_rcc.h, complaining about the macro RCC_AHBENR_ADC12EN.

I've verified that the structures are identical, and that the RCC macro refers to the same register bit.

I propose the following fix:

Code: Select all

#if defined(ADC1_2_COMMON)
  ADCD1.adcc = ADC1_2_COMMON;
#else
  ADCD1.adcc = ADC1_COMMON;
#endif


with similar constructs in stm32_rcc.h. This seems to me to leave the most room for flexibility with respect to future chip versions.

EDIT: It's likely that this is also present in the 301x8 and the 318xx -- the above fix should fix it in all versions.

Re: STM32F302x8 ADC bug (3.0.x)

Posted: Sat Nov 07, 2015 8:49 am
by Giovanni
Hi,

Thanks for finding, fixed as bug #665.

Giovanni