This programme only prints the elapsed time and the output of uBit.audio.levelSPL->getValue(), and we can see that each loop iteration takes 23 to 24 ms (a full 255 bytes buffer at 11k sample rate is 23ms):
#include "MicroBit.h"
#include "CodalDmesg.h"
MicroBit uBit;
int main() {
uBit.init();
int t_prev = uBit.systemTime();
while (true) {
int audioLevel = (int)uBit.audio.levelSPL->getValue();
int t = uBit.systemTime();
DMESG("[%d][%d] %d", t, t - t_prev, audioLevel);
t_prev = t;
uBit.sleep(1);
}
while (true);
}
Output (first iteration is expected to take longer):
relocate vtor to 0x0 -> 0x20002200 0x20002200
[115][69] 54
[138][23] 52
[162][24] 54
[185][23] 53
[208][23] 52
[231][23] 52
[254][23] 54
[277][23] 52
[300][23] 53
[323][23] 52
[346][23] 52
...
⬆️ this second column is the time between iterations
This has been tested with the latest CODAL v0.2.56.
With v0.2.55 and earlier, each loop iteration is 4ms, which would be the tick time as expected.
This programme only prints the elapsed time and the output of
uBit.audio.levelSPL->getValue()
, and we can see that each loop iteration takes 23 to 24 ms (a full 255 bytes buffer at 11k sample rate is 23ms):Output (first iteration is expected to take longer):
This has been tested with the latest CODAL v0.2.56.
With v0.2.55 and earlier, each loop iteration is 4ms, which would be the tick time as expected.