Measure CPU time of Audio library output object's ISR

Status
Not open for further replies.

Ben

Well-known member
Hi,

some of you may have noticed Frank B and me are working on a new output object for the Audio library to use the very cheap DAC PT8211 (here). This DAC has not digital output filtering, so we are experimenting with 4x oversampling and various interpolation methods (Linear, CIC, FIR) to get away fith a low order analog filter. As the (digital) filter is calculated inside the ::isr(void) function, I'd like to monitor how much CPU time it uses to do the calculations.
I tried adding digitalWriteFast(LED_BUILTIN, HIGH); and digitalWriteFast(LED_BUILTIN, LOW); at the beginning and end of the ISR respectively, but that has no effect on pin 13. (I also tried with hard-coded pin 0). I assume I can't use digitalWriteFast in the ISR? I also tried to use the AudioProcessorUsage(); and AudioProcessorUsageMax(); functions, but they don't seem to work with output object ISRs :confused:

(TL;DR) How can I measure the time the Teensy needs to complete each void AudioOutputI2S::isr(void) ( or, in my case, AudioOutputPT8211::isr(void) ) call? I'd be happy with Serial messages or anything an oscilloscope can pick up...

Thanks for your help!
-Ben
 
You can use the ARM Cortex systick timer to count clock cycles. Look at the implementation of:
hardware/teensy/avr/cores/teensy3/pins_teensy.c::micros()

digitalWriteFast should work in the ISR. It's using the standard Kinetis GPIO port set / clear registers. You did configure the pins for output mode, right?
 
You did configure the pins for output mode, right?
facepalm.jpg
Thanks.
 
Status
Not open for further replies.
Back
Top