I'm trying to get Input Capture working on a KL46Z to measure the pulse width of a PWM signal using dual input capture. Due to my familiarity and the IDE is Kinetis Design Studio as a Processor Expert Project. I've configured it to capture rising and falling edges. So in my handler (highest priority), I check the pin state and store the high time and low time accordingly. I have the timer frequency set to run nearly identical to the input signal.
My issue is the ticks for high time and low time are off by about 1-3%. I seem to be doing something wrong and have been looking for a duty cycle example with no success. I did find AN5142, but the examples reference registers that are not in the KL46z (e.g. FTM0_COMBINE). I suspect that AN5142 is specific for K series and not L. As one last ditch effort, I downloaded the FRDMKL46Z SDK using MCUxpresso and the only example was a single rising edge example.
Any ideas why the ratio between high and low ticks has a high error?
Hi @rppolicy ,
You are uing the TPM module right? Could give more details of the clock being used as source for the timer? Please notice that the clock accuracy is different for the internal reference clocks:
• 48MHz high accuracy (up to 0.5%) internal reference clock
• 8MHz/2MHz high accuracy (up to 3%) internal reference clock
Could you also provide more details of the frequency of the input signal you are capturing? Note that the maximum frequency for the channel input signal to be detected correctly is counter clock divided by 4.
Regarding the AN5142, you are correct, this FlexTimer module is not present in the KL46Z devices.
Regards,
Carlos Mendoza
Field Applications Engineer
Thank you for the reply Carlos.
Yes, I am using TPM1 - specifically channel 0. The measured signal has a frequency of 250Hz (4mS period). I'm using the Processor Expert, and according to the parameters, the clock is running at 12.5MHz. The TU indicates the "Maximum time of event" is 5.24288mS, which seems reasonable for a timeout value for my signal.
- Rick