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_IOCON_SetPinConfig(NSS_IOCON, IOCON_ANA0_0, IOCON_FUNC_1);
int i = 0;
//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?