3 Replies Latest reply on Sep 17, 2016 1:06 PM by user_1377889

    Faster method to read the ADC

    user_418894472

      My ADC is running at 12MHz, it samples 5 channels and the actual sampling rate is 100KHz.

         

      I just noted that reading a single channel using the ADC_GetResult16() command takes a whooping 1us at 48MHz CPU speed.

         

      It takes over 5us to read the 5 channels. Now at 100KHz sampling rate, time between two successive samples is 10us out of which 5us is wasted in simply reading the ADC. Only 5 remains for performing other calculations before the next sample arrives.

         

      This is very very slow. In fact what sense does it make if the ADC runs at 1MSPS and takes another 1us to read the channel.

         

      Is there a faster method to read the ADC channels?

         

      Can't we directly read the channel resistors?

         

      Thanks

        • 1. Re: Faster method to read the ADC
          user_1377889

          You may use a PSoC4-M which has got DMA. So you can shovel the data to a buffer and work on it while the next data gets sampled and transmitted. This requires after setup no CPU intervention except the interrupt handling.

             

          Reading (as recommended) the result registers directly in an eoc handler woud be quite suficient.

             

          for (chan = 0;chan < MAXCHANNELS; chan++)

             

          {

             

                  *ResultVector++ = CY_GET_REG32((reg32 *)(ADC_SAR_SAR_CHAN_RESULT_IND + (uint32)(chan << 2u))) &
                          ADC_SAR_RESULT_MASK;

             

          }

             

          You can set for a file the compiler optimization individually, so the rest of the project can be debugged.

             

           

             

          Bob

          • 2. Re: Faster method to read the ADC
            user_418894472

            Thanks Bob for the quick response.

               

            POSC-4M sounds interesting. Time for me to take a deeper look at it.

               

            Meanwhile, the method above  for reading the ADC registers directly, has reduced the channel read time from 1us to 189ns! It works well enough for me to ignore the M for some more time. Feeling Happy :)

               

            Thank you!

            • 3. Re: Faster method to read the ADC
              user_1377889

              You are always welcome!

                 

              Get hands on a CY8CKIT-043 with a PSoC4-M

                 

               

                 

              Bob