cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F100 ADC Setup

tsjarvis91
Associate
Posted on February 05, 2015 at 17:05

Hi,

Im trying to get the ADC working on the STM32f2100RB Discovery board. The code keeps getting stuck in the underlined, bold line of code.

****ADC Setup code****

void Config_ADC1DAC1 (void){       //ADC Set-up

    GPIOA->CRL|=(0x0000);             //Enable GPIOA - Analogue input mode

    GPIOB->CRL|=(0x0000);

    RCC->APB2ENR|=((0x01<<2) | (0x1<<9));             //Enable ADC1

    ADC1->SR&=~0x02;                              //EOC cleared

    ADC1->CR1|=((0x01<<8));                        //Scan mode

    ADC1->SQR1|=(0x01<<20);           //Number of conversions - Two ADC's

    ADC1->SQR3|=((0x01<<(5*0))|(0x02<<(5*1)));                    //PA1, PA2

    ADC1->CR2|=((0x01<<0)|(0x01<<1));                      //ADC started, EOCS set

  

***Reading ADC***

ADC1->CR2|=(0x01<<22);                                        //Start a regular group conversion

   for(c=0; c<2; c++)                                                //For loop, two ADC's

    {

       

while(!(ADC1->SR&0x02));                 //wait for conversion complete

       adc_data[c]=(ADC1->DR);                  //Read data from buffer

    }

Can anyone see a problem with the setup code? This works perfectly fine with the STM32f4discovery board (with a few tweeks).

Thanks

Tom

#adc #stm32f100rb #stm32f1 #set
0 REPLIES 0