Testing if a function is too long to fit in the audio callback

I’ve written a function that i suspect may be too long to execute in the audio callback. Are there any tests/debug features I can use to verify this?

The function runs once after a buffer is filled. I have verified that the function works as expected with my st-link debugger but yet there is still a lot of crackling which i assume is caused by the function over running.

yes! this was solved here: [SOLVED] How to do MCU utilization measurements - #3 by StaffanMelin

I’m using it my code, its easy to integrate:

  1. import this lib: daisy1/main.cpp at d91e4efb311202c0b34821c616ab2ec5a7a49891 · schollz/daisy1 · GitHub
  2. setup the code in the main loop: daisy1/main.cpp at d91e4efb311202c0b34821c616ab2ec5a7a49891 · schollz/daisy1 · GitHub
  3. start measurement at the beginning of callback: daisy1/main.cpp at d91e4efb311202c0b34821c616ab2ec5a7a49891 · schollz/daisy1 · GitHub
  4. save result to global variable at end of callback: daisy1/main.cpp at d91e4efb311202c0b34821c616ab2ec5a7a49891 · schollz/daisy1 · GitHub
  5. use the Log library and print out the percentage of the audio block used: (float)audiocallback_time_needed / CYCLES_AVAILBLE * 100.0f (audiocallback_time_needed is my global variable).
2 Likes