2013-02-02 12:18 AM
Quick background: I'm using the STM32VL which has 1 ADC peripheral with a possible 18 channels inputs that are multiplexed to the actual ADC. I believe I have the configuration set up correctly for 2 analog inputs. My question lies in the sampling technique... The way I understand the ADC to work on this board is that it has a single data register, so when I scan multiple analog inputs, I have to read the data in between samples using either flags, interrupts or DMA. I chose to use the EOC flag. What I want to do is after the first sample is finished, store the data in ADCResult_1 and when the second sample is complete, store that into ADCResult_2. This is my code but I dont think is correct since this would store the same value in both ADCResult_1and ADCResult_2:
while(ADC_GetFlagStatus (ADC1, ADC_FLAG_EOC) == RESET); ADCResult_1 = ADC_GetConversionValue(ADC1); // sample 1 while(ADC_GetFlagStatus (ADC1, ADC_FLAG_EOC) == RESET); ADCResult_2 = ADC_GetConversionValue(ADC1); // sample 2Any suggestions on how to capture each successive sample repeatedly?2013-02-02 02:27 AM
Any suggestions on how to capture each successive sample repeatedly?
Make sure the sample/conversion rate is slower than your ability to read out values. This will include whatever time is needed to service other interrupts, etc. DMA is used so you don't have to grind the processor in this fashion.
2013-02-02 07:24 AM
Supposing that my sample rate is adequate, would my code work using the EOC flag?
2013-02-02 08:05 AM
Supposing that my sample rate is adequate, would my code work using the EOC flag?
I don't know, it appears the most inefficient way to do it, I have not investigated. What's the driver for doing it this way instead of reading them into an array in a paced/controlled way?2013-02-02 08:39 AM
2013-02-02 08:40 AM
The only driver for doing it this way is my lack of experience...I agree this way seems to be very inefficient. I suppose a better way is to create an interrupt service routine that stores the value after each sample conversion. Don't know how to really do that just yet though, which means I need to do some research.