If you only had enough time to fully finish executing the “compute the beat” code or “flash leds”, I think you would put priority on “compute the beat” because at least you could record that a beat happened.
Is my assumption correct?
Sent from my iPhone using Tapatalk Pro
Running two concurrent threads
Re: Running two concurrent threads
right. but even if i do it that way i can only sample 1000 times per second, right?
Re: Running two concurrent threads
No.hdsjulian wrote:right. but even if i do it that way i can only sample 1000 times per second, right?
One thing you have to understand is documentation is terribly incomplete.
The documentation says you can only do interrupts down to 1ms but the uPy source code shows you can do it much faster.
ports/esp32/machine_timer.c
It shows there’s a freq argument that you can use instead of the period argument.
There’s another issue: interrupt jitter.
You’re sampling audio so sampling exactly every X ms is critical.
Unfortunately the implementation of the timer isr does not call the uPy callback in the isr.
Instead, it uses mp_sched_schedule to schedule it to be executed “as soon as possible” which will introduce jitter.
What interface are you using to sample the microphone?
Sent from my iPhone using Tapatalk Pro
Re: Running two concurrent threads
true. but this won't keep me from only sampling 1000 inputs per second?
Re: Running two concurrent threads
Nohdsjulian wrote:true. but this won't keep me from only sampling 1000 inputs per second?
Sent from my iPhone using Tapatalk Pro
Re: Running two concurrent threads
sorry my second comment was useless. don't know how i double posted this
Re: Running two concurrent threads
using the ADC interface. it's a max4466 electret microphone