cancel
Showing results for 
Search instead for 
Did you mean: 

Multi-Channel ADC Configuration And ADC output Data differentiation corresponds to Specific Channel

manishbaing2789
Associate II
Posted on November 11, 2013 at 10:33

Hello,

 I am working with STM32F4 Discovery with FreeRTOS and summon arm tool chain.I am sending ADC  data over serial Port using USB serial communication.I have write code to get ADC value in continuous conversion mode with ADC1 and channel 12.But now I have to perform Multi-channel conversion mode.So I have following Doubts please guide me regarding that

1) I have refered Datasheet of STM32F4 Discovery so I came tw know that there are 16 channel but out of them how many are available..?

2)I have to connect 6 sensors to ADC channels as below

         ADC_1 Channel_11(PC1) ----> Sensor1

         ADC_1 Channel_12(PC2) ----> Sensor2

         ADC_1 Channel_15(PC5) ----> Sensor3

         ADC_1 Channel_14(PC4) ----> Sensor4

         ADC_1 Channel_9 (PB1) ----> Sensor5

         ADC_1 Channel_8 (PB0) ----> Sensor6

So above Channels available or not...?

3) I have to get converted data from all channels .But how I can differentiate data of particular channels..?

i.e   when I have get data by statement below

 val= (int)ADC_GetConversionValue(ADC1); Then how I could Differentiate and Display Data of Particular channel..?

4) Suppose I Have to print 

          printf(''Channel11_data %d\n'',val); then

          printf(''Channel12_data %d\n'',val);

            .

            .

            .

          printf(''Channel_data8 %d\n'',val);

For above thing to be done what are all the thing related to configuration and other I need to do..? plz guide me regarding that.

#multi-channel-adc
5 REPLIES 5
Posted on November 11, 2013 at 10:48

I think I've counted and enumerated them before, please check prior posts. You'll need the Data Manual for the part, and the User Manual for the board. You should be able to identify the free/usable pins.

For multiple channels you're supposed to use DMA, and an array that is a multiple of the sample list, you can then fish out your results in sequence from the array at TC and HT DMA interrupts. I've posted examples, and there should be others in the firmware libraries.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
manishbaing2789
Associate II
Posted on November 11, 2013 at 11:30

Thanks a Lot  clive1

''For multiple channels you're supposed to use DMA'' 

 

Why it is so..?

actually I not aware about programming uisng DMA

So will  plz explain me why we can't use Interrupts for same and why u suggested DMA ..?

Will u please mentioned link regarding what u have mentioned  ..?if possible  then it will be very helpful for me. Because I have searched lot related to mentioned problem but i was not able to get specific post.Thanks a  lot again for your valuable  Responce. 

Posted on November 11, 2013 at 13:41

The primary reasons would be ones of speed and practicality. At 1Msps you're not going to be able to use interrupts to service the ADC, and the ADC does not provide an index. DMA puts them in an ordered array, the TC interrupt is the equivalent to a group EOC signal.

''13.8 Data management

 

13.8.1 Using the DMA

 

Since converted regular channel values are stored into a unique data register, it is useful to use DMA for conversion of more than one regular channel. This avoids the loss of the data already stored in the ADC_DR register.

 

When the DMA mode is enabled (DMA bit set to 1 in the ADC_CR2 register), after each conversion of a regular channel, a DMA request is generated. This allows the transfer of the converted data from the ADC_DR register to the destination location selected by the

 

software.''
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
manishbaing2789
Associate II
Posted on November 13, 2013 at 07:43

Once again Thanks clive1 for your valueable and Helpful responce. 

I want to ask few things after this as follows

1) I am using Two channel of ADC1 in continous mode and I want to print data continuously and at a time from both channels ..so how i can do it..?

e.g I have decalred 

  uint32_t ADC1_convertedValue[2];

  then....

  DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&ADC1ConvertedValue; 

   .

   .

   .

...main function...

  while(1)

{

 val_ADC1_channel11 = ADC1ConvertedValue[0];

  val_ADC1_channel12 = ADC1ConvertedValue[1];

 printf(''Channel11_data %d\n'',val_ADC1_channel11); 

 printf(''Channel12_data %d\n'',val_ADC1_channel12);

}

..................

I want output of two statements as follows

Note : all values as randum and assumed by Myself

 Channel11_data 2049 

 Channel12_data 2016

 Channel11_data 1826

 Channel12_data 1650

 Channel11_data 2144

 Channel12_data 1866

 .

 .

 .

and so on....

I think it may possible.I want to just confirm from you that it is so or not...?

Posted on November 13, 2013 at 08:18

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/3%20channels%20on%20ADC1%20and%20DMA&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=268]This thread about 7/8 th down

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..