Skip to main content
mcdamn
Visitor II
June 1, 2010
Question

STM32F10x_StdPeriph_Examples ADC RegSimul_DualMode

  • June 1, 2010
  • 1 reply
  • 1007 views
Posted on June 01, 2010 at 10:29

STM32F10x_StdPeriph_Examples ADC RegSimul_DualMode

    This topic has been closed for replies.

    1 reply

    raptorhal2
    Lead
    May 17, 2011
    Posted on May 17, 2011 at 13:53

    You need to make three changes:

    First make the DMA buffer size equal to the number of ADC sample channels.

    Set up a loop to sample the analog channels. I used a Timer2 interrupt handler, you use whatever is appropriate, which could be as simple as a loop with no loop timing control.

    Enable the DMA and the ADC conversion at the start of your loop. After you have read the DMA buffer,  disable the DMA, reset the DMA counter to the sample buffer size, and repoint the DMA address register to the start of the sample buffer.

    Here is the code I used. I wanted to get as little library overhead as possible, so I used inline code instead of the library in some places.

    (Usual DMA and ADC setup code here)

    //Loop Start

      DMA_Channel1->CCR |= 0x00000001;         //Enable DMA Channel 1

      ADC_SoftwareStartConvCmd(ADC1, ENABLE);    //Start conversion

    (Test for conversion complete and sample the results here)

    //Loop Finish:

       DMA_Channel->CCR &= 0xFFFFFFFE;     //Disable DMA Channel1

       DMA_Channel1->CNDTR = 9;                     //Reset DMA buffer count (I sample 9 channels)

       DMA_Channel1->CMAR = (u32)&MyADCBuffer;

    Cheers, Hal