kopia lustrzana https://github.com/kosme/arduinoFFT
Merge pull request #21 from edgar-bonet/fix-rollover
FFT_03.ino: fix micros() rollover issue and sampling frequencypull/22/head
commit
a060c2f7d1
|
@ -53,15 +53,15 @@ void setup()
|
|||
void loop()
|
||||
{
|
||||
/*SAMPLING*/
|
||||
microseconds = micros();
|
||||
for(int i=0; i<samples; i++)
|
||||
{
|
||||
microseconds = micros(); //Overflows after around 70 minutes!
|
||||
|
||||
vReal[i] = analogRead(CHANNEL);
|
||||
vImag[i] = 0;
|
||||
while(micros() < (microseconds + sampling_period_us)){
|
||||
while(micros() - microseconds < sampling_period_us){
|
||||
//empty loop
|
||||
}
|
||||
microseconds += sampling_period_us;
|
||||
}
|
||||
/* Print the results of the sampling according to time */
|
||||
Serial.println("Data:");
|
||||
|
|
Ładowanie…
Reference in New Issue