STM32F10x_StdPeriph_Examples ADC RegSimul_DualMode
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2010-06-01 1:29 AM
Posted on June 01, 2010 at 10:29
STM32F10x_StdPeriph_Examples ADC RegSimul_DualMode
This discussion is locked. Please start a new topic to ask your question.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2011-05-17 4:53 AM
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