I'm using KL05 with Processor Expert on KDS 3.2.0.
I need to measure the time between two rising edges without the error caused by interrupt latency. The level must be variable using the DAC and Comparator.
I'm having trouble capturing pulses using the CMP0 to trigger TPM1, channel 0 capture.
The capture value is not changing (it does infrequently), however the interrupt flag is being set (the CMP0 interrupt is enabled, but not the TPM1 capture interrupt).
In PE, I have TimerUnit_LDD component with Channel 0 set for Capture mode, and the "Capture input pin" is set to "CMP0_output".
I already found this was missing from PE generated code: (from the reference manual table 3-1, page 44)
SIM_SOPT4 |= SIM_SOPT4_TPM1CH0SRC_MASK; // Enable CMP0 -> capture TPM1CH0
But even after adding that, the result of TPM_PDD_ReadChannelValueReg(TPM1_BASE_PTR, 0) doesn't change after every pulse.
Any ideas? Any example programs that do this?
If capture is broken, can I use DMA to achieve period measurement (seems over-complicated)?