AnsweredAssumed Answered

STM32F100C6, ADC & DMA

Question asked by kyosev.peter on Jun 9, 2014
Latest reply on Jun 12, 2014 by kyosev.peter
Hello,
I have a problem with configuring ADC & DMA. This is the code
ADC

RCC -> APB2ENR |= RCC_APB2ENR_ADC1EN;
ADC1 -> CR1 |= ADC_CR1_SCAN;
ADC1 -> CR2 |= ADC_CR2_EXTSEL_0 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_2;
 ADC1 -> CR2 |= ADC_CR2_CONT;    
 ADC1 -> SMPR2 |= ADC_SMPR2_SMP1_0 | ADC_SMPR2_SMP1_1; 
       ADC1 -> SMPR2 |= ADC_SMPR2_SMP2_0 | ADC_SMPR2_SMP2_1;
   ADC1 -> SQR3 |= ADC_SQR3_SQ1_0 | ADC_SQR3_SQ2_1;
     ADC1 -> CR2 |= ADC_CR2_ADON;
     ADC1 -> CR2 |= ADC_CR2_RSTCAL;
       while (((ADC1 -> CR2) & ADC_CR2_RSTCAL) == ADC_CR2_RSTCAL) {}
       ADC1 -> CR2 |= ADC_CR2_CAL;
       while (((ADC1 -> CR2) & ADC_CR2_CAL) == ADC_CR2_CAL) {} 
       ADC1 -> CR2 |= ADC_CR2_SWSTART | ADC_CR2_EXTTRIG;  

DMA
RCC  -> AHBENR |= RCC_AHBENR_DMA1EN;
       DMA1_Channel1 -> CCR   |= DMA_CCR1_CIRC;
       DMA1_Channel1 -> CCR   |= DMA_CCR1_MINC;
       DMA1_Channel1 -> CCR   |= DMA_CCR1_PSIZE_0;
       DMA1_Channel1 -> CCR   |= DMA_CCR1_MSIZE_0;
       DMA1_Channel1 -> CCR   |= DMA_CCR1_PL_1;
       DMA1_Channel1 -> CNDTR |= 0x02;
       DMA1_Channel1 -> CPAR   = (uint32_t)&ADC1->DR;
       DMA1_Channel1 -> CMAR   = (uint32_t) &Battery -> AdcValue;
       DMA1_Channel1 -> CCR     |= DMA_CCR1_EN;
     ADC1 -> CR2    |= ADC_CR2_DMA;


Port
A.1
GPIOA -> CRL &= ~(0x0F<<4);                                             
  GPIOA -> CRL &= ~(0x03 << 6);                                                         // Analog mode
    GPIOA -> CRL &= ~(0x03 << 4);               
A.2
GPIOA -> CRL &= ~(0x0F << 8);                                                       // Clear old value
  GPIOA -> CRL &= ~(0x03 << 10);                                                        // Analog mode
    GPIOA -> CRL &= ~(0x03 << 8);  


The problem is that I can measure voltage only on Port A.1 and i want Port A.2 too.

Outcomes