- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content