Sub-millisecond timer output compare interrupt

I’ve been toying with an Electron for a while; all going well - thanks largely to this community. Thanks to all…

In my application, I’ve written code to sample noise in direct bursts (1000 samples in a loop) to do some post processing (FFT’s etc). However - I would like to make the system a little smarter by allowing continuous noise monitoring (i.e. through at fixed interval timer interrupts). Then post process the noise of there is an event “of interest”.

The “Timer” function out of the box seems to have millisecond (up to 1kHz) resolution. But I need to get this thing up to in the order of 40kHz (i.e. 2x the sample frequency range I’m interested in - which is up to 20kHz). Not a problem with the burst mode sampling (this gets up to ~110kHz).

Any examples (showing how to do a custom timer output compare @ 40kHz) would be great!

Thanks in advance.

You can have a try with the SparkIntervalTimer library which is interrupt driven an should be good down to 10µs.

And there are some samples by @rickkas7 that also feature timer driven ADC