hello,
I am using the following code to have a sampling frequency of 10 kHz specifies. The problem is that the vector of samples (dataV[])is only filled to the 22 position.
#define ARM_MATH_CM3
#include <arm_math.h>
#define samples 200
float32_t dataV[samples];
void setup() {
Serial.begin(9600);
/*
ADC:
ADC_FREQ_MIN = 1000000
ADC_STARTUP_FAST = 12 us
*/
analogReadResolution(12);
adc_init(ADC, SystemCoreClock, ADC_FREQ_MIN, ADC_STARTUP_FAST);
}
void loop() {
float stp = 0;
float start = micros();
for (int i = 0; i < samples ; i++)
{
if((stp-start)<= 20000) //collect samples during 20ms
{
dataV[i] = analogRead(A0)*(3.3/4096);
delayMicroseconds(100); //wait 0.1ms
stp = micros();
}
}
for(int i = 0; i < samples ; i++)
{
Serial.print("[");
Serial.print(i);
Serial.print("]: ");
Serial.println(dataV[i]);
Serial.print("\n");
}
while(1){
}
}