AnsweredAssumed Answered

NHS3152: How can I store ADC conversions near the 12kS/s rate?

Question asked by Randall Irwin on Mar 29, 2019
Latest reply on Apr 5, 2019 by Mario Ignacio Castaneda Lopez

Hello,

 

I need to store ADC samples at a minimum of 2kS/s, and was expecting to reach closer to 12kS/s per the datasheet, but I am getting a rate around ~200S/s. I am not sure if this is due to the way I am retrieving the samples and storing them, or some other part of my code. I store the samples in an int array, then store the 32bit timer count in a separate int array. Here is the relevant code from my main function:

 

AppInit(); //This is borrowed from the ndeft2t example code
Chip_TIMER32_0_Init();
Chip_TIMER_Enable(NSS_TIMER32_0);
Chip_ADCDAC_Init(NSS_ADCDAC0);
Chip_ADCDAC_SetMuxADC(NSS_ADCDAC0, ADCDAC_IO_ANA0_0);
Chip_IOCON_SetPinConfig(NSS_IOCON, IOCON_ANA0_0, IOCON_FUNC_1);
Chip_ADCDAC_SetModeADC(NSS_ADCDAC0, ADCDAC_CONTINUOUS);
Chip_ADCDAC_SetInputRangeADC(NSS_ADCDAC0, ADCDAC_INPUTRANGE_NARROW);
Chip_ADCDAC_StartADC(NSS_ADCDAC0);


int i = 0;
int samples[5];
int time[5];


for (i;i<5;i++){
//Record ADC samples and timestamp in milliseconds
samples[i] = Chip_ADCDAC_GetValueADC(NSS_ADCDAC0);
time[i] = Chip_TIMER_ReadCount(NSS_TIMER32_0);
}

 

 

 

When I output the values from the two arrays, my actual sample frequency according to the 32bit timer is ~200Hz. To calculate this I convert the timer to seconds by dividing by the system clock frequency (set to 8MHz, prescaler is set to 0), then take the difference between two successive samples and invert (f = 1/(t1 - t0)) Could you please recommend an alternate method or point me in the right direction?

 

Thank you,

Randall Irwin

Outcomes