Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use delayMicroseconds() in examples instead of less accurate empty active wait loop. #35

Open
JM-FRANCE opened this issue Oct 26, 2019 · 0 comments

Comments

@JM-FRANCE
Copy link

JM-FRANCE commented Oct 26, 2019

instead of doing
microseconds = micros(); for(int i=0; i<samples; i++) { vReal[i] = analogRead(CHANNEL); vImag[i] = 0; while(micros() - microseconds < sampling_period_us){ //empty loop } microseconds += sampling_period_us; }

it's easier and more arduino like to do

for(int i=0; i<samples; i++) { vReal[i] = analogRead(CHANNEL); vImag[i] = 0; delayMicroseconds(sampling_period_us); }

delayMicroseconds() will perform likely more accurately than your active wait esp. if the sampling period is small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant