I have been trying to get an application to work which uses CMP0 to generate interrupt calls to the associated callback.
It is a bare metal application so no OS whatsoever. The only thing i am using is the generated code from the Processor expert to set up the CMP0 component and defining the call back function.
I need to be able to measure the timing between respective falling and rising edges with a 1μs resolution, the shortest period between 2 edges is +/- 6 μs. the longest +/- 100 μs.
The 1 μs resolution is trivial, I use a TPM module set up as a free running counter counting at 1 MHz and read the current value using the "TPM_DRV_CounterRead" function.
I have checked that it does effectively work, when I apply a 1 kHz signal to my signal input It duly measures 500 μs ( +/- 1 ) between each rising and falling edge of the signal.
However, when I try to measure the much faster signals I need the minimal measured difference is +/- 20 μs.
Other than determining the difference between two edges my Callback function does little else so I guess that is not the problem.
Therefore I think there is a pretty large amount of overhead in calling the CallBack function. Does anyone have an idea as to how much overhead there is on a KL03 running at 48 MHz ?
Any help very much appreciated.