cancel
Showing results for 
Search instead for 
Did you mean: 

What is correct sequence of reading two adc pins

aamirali641989
Associate II
Posted on August 29, 2013 at 07:47

What is correct sequence of reading two adc pins in software control mode of module ADC1

I have to scan 14 & 9 channel but under software control mode .

while(1)

 

{

 

  SQR3 = 0x0E;   /* select 14 channel to scan  */

 

  CR2 |= SWSTART;    /* start the conv */ 

 

  while( !EOC );            /* while end of conversion */

 

  data = DR;                 /* read data */

 

 

 

  SQR3 = 0x09;   /* select 9 channel to scan  */

 

  CR2 |= SWSTART;    /* start the conv */ 

 

  while( !EOC );            /* while end of conversion */

 

  data = DR;                 /* read data */

 

 

}

1 REPLY 1
raptorhal2
Lead
Posted on August 29, 2013 at 15:42

You do have a sequence here that is software control. Call the results data1 and data2 to keep the results distinct.

The elegant way is to program the ADC in scan mode, DMA 2 word buffer, and read the results when the DMA flags complete. Up to the all channels on that ADC can be read with one start command. Read the user manual for more details.

Cheers, Hal