Hi NXP stuff,
Now I am working on NXP FRDM-K64F, I am trying to implement a frequency measurement module.
I am using SDK example and make some modification.
I have tried single edge and dual edge capture mode. and finally I found there dual edge has better performance than single edge capture mode.
Then, I was try to test the cap frequency, because base on the document ( Document Number: K64P144M120SF5RM, Rev. 2, January 2014) , it mentioned " Note that the maximum frequency for the channel input signal to be detected correctly is system clock divided by 4, which is required to meet Nyquist criteria for signal sampling." ( chapter 40.4.4, page 1011) . I believe dual edge capture mode should has same requirement ( please correct me if I am wrong )
According to the example code, FTM using System clock ( which is bus clock), default bus clock is half of core clock ( 60MHz), and I have change it to 120MHz in my test code.
I have test the input frequency from 10KHz to 30MHz, but I found some issue :
my source code has been attached, and the original example project is : frdmk64f_ftm_dual_edge_capture
please kindly assist, thanks
Hi,
First thing here that caught my attention here is that you are exceeding the bus clock maximum frequency. Please check the table below from the reference manual.
Please try to use bus clock withing the allowed range. I think this could be the main issue of the incorrect frequency you are measuring.
Best regards,
Felipe
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored. Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
------------------------------------------------------------------------------
Hi Felipe,
Currently I am using eDMA to grab data from CnV for single edge capture mode and dual edge capture mode.
Bus clock is 60MHz
Based on the document, theoretically the maximum frequency can be captured is clock/4 = 15MHz,
And as I mentioned, there has no interrupt generated once frequency exceed 10MHz which is clock/6
Now, I found a weird behavior, the CnV value will become incorrect when the input signal frequency between 7MHz to 10MHz ( such as : input frequency is 8MHz, but the calculated result is 4MHz which base on the captured count)
last time I thought it is because of ISR speed too slow, so I think eDMA should can solve this issue. but base on the weird behaviors, it looks like hardware issue. ( because the result for using DMA is same as I use FTM interrupt )
So, is this behaviors caused by the hardware limitation ? or do you have any example can capture input signal frequency up to 15MHz ?
Thanks & Best Regards
Joshua
Hi Joshua,
Unfortunately, we do not have more example to share than what is already included in the SDK. I agree that ISR could indeed add delay due to interrupt latency. I am also thinking this could be related to SW overhead that could be caused by SDK and drivers.
Also from what I could see in the different thread you are submitting here: https://community.nxp.com/t5/Kinetis-Microcontrollers/Input-Edge-Capture-Mode-Upper-Limiting-Frequen... you are using printf so this could be interfering as well.
Best regards,
Felipe
Hi Felipe,
Thank you for your reply.
The PRINTF is not in ISR thread, does it still affect the speed ?
in order to avoid ISR processing speed issue , I have change the ISR implementation to eDMA . and I have disable FTM filter. but the behaviors is till unexpected:
eDMA captured value is unexpected when the input signal frequency exceed 7MHz ( as I said before, calculated result is 4MHz for a 8MHz input signal)
at first I thought it's eDMA performance issue, but according to description of eDMA : chapter 22.4.4.3
“For an internal peripheral bus to SRAM transfer, PEAKreq = 150 MHz / [ 4 + (1 + 2) + (1 + 1) + 3 ] cycles = 12.5 Mreq/sec”
The example system operates at 150MHz, and our system operates at 120MHz, so the PEAKreq should be 10Mreq/sec
therefore my understanding is : eDMA should not affect the result when the input signal frequency below 10MHz, did my understanding correct?
If I am right, then it become FTM hardware performance issue again. could you help me to double confirm with your hardware design team?
Thanks & Best Regards
Joshua
Hi Joshua,
Thank you for your reply. Just want to let you know that I am currently checking this with our internal team to see if there is an issue with FTM module. I will let you know as soon as I receive an update.
Best regards,
Felipe
Thank you Felipe
Hi Joshua,
I have received confirmation from internal team, it seems that is expected behavior, please check below.
That is a normal behavior and the reasoning as follows:
As you said: *maximum frequency can be captured is clock/4 = 15MHz.*. so the min. time quanta is 1/15Mhz = 0.066666666us. for example, your input signal is 8Mhz, 50% duty cycle PWM. the time between two falling edge is 1/8Mhz = 0.125us
so if you measure 8Mhz, the CnV value will be 0.125 / 0.0666 = 1.87. this can either possible results a 1 or 2 in CnV resistor. which you only get 15Mhz or 7.5Mhz. (I don't why customer got a 4Mhz result..)
In a word, the FTM's input clock must be high enough compared with input signal, to get a correct measurement result.
Best regards,
Felipe
Hi Felipe,
Thank you for your reply.
1st, I am agree with your colleague, so what I did in the experiment is :
2nd, for the 4MHz result I had a suspicion:
Therefore the calculated result been halved.
But, it is inconsistent with the description in the user manual if my suspicion is correct. eDMA performance should able to process 10M request when system frequency is 120MHz
and FTM input capture mode could generated interrupt correctly when input frequency below 15MHz.
So I don't know which module has slow down the system... that makes me confused. could you give me some help.
Thanks & Best Regards
Joshua
Hi Joshua,
Your experiment is not totally clear to me but as mentioned I think this is limitation of the FTM module so I do not think you can achieve such high frequency with input capture mode. Sorry for the inconvenience.
Best regards,
Felipe
Hi Felipe,
Thank you for your reply and your suggestion.
Actually I have tested 60MHz also, the interrupt cannot be received once the input frequency exceed 10MHz, that is similar like 120MHz : interrupt cannot be received once the input frequency exceed clock_freq/6 which is different as the document mentioned clock_freq/4.
That makes me quite confused, do you have any idea ?
Thanks & Best Regards
Joshua