2014-02-18 08:46 AM
Hi,
I'm working with stm32F0discovery, andI'm trying to develop ADC single conversione mode. This is my code of init ADC:uint32_t tmpreg = 0;
/* ADC1 Periph clock enable */
RCC->APB2ENR |= RCC_APB2ENR_ADC1EN;
/* ADCs DeInit */
RCC->APB2RSTR |= RCC_APB2ENR_ADC1EN;
RCC->APB2RSTR &= ~RCC_APB2ENR_ADC1EN;
tmpreg = ADC1->CFGR1;
/* Clear SCANDIR, RES[1:0], ALIGN, EXTSEL[2:0], EXTEN[1:0] and CONT bits */
tmpreg &= (uint32_t)0xFFFFD203;
//resolution 12 bit 0x0000000
//Continuous mode DISABLE
// NO EXTEN e NO EXTSEL
//data align right = 0
//scan direction upward
tmpreg |= (uint32_t)(0x00000000 | ((uint32_t)(DISABLE) <<
13
) |
0x00000000 | 0x00000000 | 0x00000000| 0x00000000);
ADC1->CFGR1 = tmpreg;
//channel 3 - 5
ADC1->CHSELR |= (uint32_t)ADC_CHSELR_CHSEL3; // channel 3
ADC1->SMPR = (uint32_t)0x00000003;
/* Enable ADC1 */
ADC1->CR |= (uint32_t)ADC_CR_ADEN;
/* Wait the ADRDY flag */
while((ADC1->ISR & 00000001) == 0);
/* ADC1 regular Software Start Conv */
ADC1->CR |= (uint32_t)ADC_CR_ADSTART;
When I set start conversion, the bit AD START of ADC_CR register doesn't set. Why?
Thanks
2014-02-19 07:40 AM
Does conversion happen ?
Apparently no one is willing to check if every ADC register bit has been correctly set by your code. I suggest you code this with library calls and see if the problem repeats. Cheers, Hal2014-02-19 11:35 AM
To add to that, there are nice ADC example projects for the F0 discovery to build upon, downloadable from the ST website.
I'm, too, shying away from the tedious task of register bit decoding ...