I am working on a project involving a crank signal (36-2) and using the FTM Input Edge Capture block to detect the falling edges. The configuration is as follows:
FTM Input Edge Capture Block:
- Configured for falling edge detection.
- Outputs a timestamp for each falling edge.
- Triggers a function that counts the number of edges and resets back to 0 when needed.
Periodic Interrupt Timer Block:
- Configured with a period of 30 microseconds.
- Triggers another function every 30 microseconds.
- This function increments a counter, which is reset by the function triggered by the FTM Input Edge Capture block.
Issue:
As the complexity of the logic within the function triggered by the FTM Input Edge Capture block increases, the execution time for this function also increases. This results in a delay between the blue signal (input to the block) and the yellow signal (output of the command block).
Additionally, the function triggered by the 30-microsecond interrupt timer introduces further delay in the logic due to its execution time. This compounding delay is evident in the attached oscilloscope capture:
- Channel 3 (Blue): Input signal to the FTM Input Edge Capture block.
- Channel 1 (Yellow): Output of the function triggered by the FTM Input Edge Capture block.
- Channel 4 (Pink): Delay caused by the interaction between the 30-microsecond timer and the FTM Input Edge Capture block.
Question:
How can I minimize or manage the execution delays caused by these interactions? Specifically:
- Is there an optimized way to handle the logic within the function triggered by the FTM Input Edge Capture block to reduce its execution time?
- Would offloading some of the calculations to a different task or interrupt level help mitigate these delays?
- Are there any best practices for using the Periodic Interrupt Timer and FTM Input Edge Capture blocks together to avoid cascading delays?



