You are here

Faster method to read the ADC | Cypress Semiconductor

Faster method to read the ADC

Summary: 3 Replies, Latest post by Bob Marlowe on 17 Sep 2016 01:06 PM PDT
Verified Answers: 0
Last post
Log in to post new comments.
MrinalMani's picture
User
64 posts

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

user_1377889's picture
User
9842 posts

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

 

MrinalMani's picture
User
64 posts

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!

user_1377889's picture
User
9842 posts

You are always welcome!

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

 

Bob

Log in to post new comments.