KV58F FTM1 used to count encoder

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KV58F FTM1 used to count encoder

756 Views
a8Chcx
Contributor V

Hi,

I am running the FTM_quad_decoder sample project and turning encoder in the same speed.

If choose pre-scale=128, counts is about 243.

if choose pre-scale=64, counts is about 483

....and so on...

Can anybody tell me where the problem is?

Thanks,

Christie

Labels (1)
0 Kudos
7 Replies

498 Views
egoodii
Senior Contributor III

You're not giving us anything to go on, so I can only guess that you are NOT getting 'quadrature mode' on this FTM, but rather using one phase as some form of FTM1_CLKIN.

0 Kudos

498 Views
a8Chcx
Contributor V

Hi Earl,

I just use the FTM_quad_sample for TWR-KV58F, and connect the encoder PHa and PHb on PE20&PE21.

I got the encoder counts. The question is why the counts are changing based on pre-scale? It should not be related to pre-scale, right? Or it is related to pre-scale and how to set pre-scale?

Thanks,

Christie

0 Kudos

498 Views
a8Chcx
Contributor V

Hi Earl,

I tested with the encoder with 6K frequency, I can get the counts around 24000/s if I use pre-scale=1.

I can get counts around 750/s if I use pre-scale=32.

If I use the encoder on TWR-KV58F, I can get the counts is around 24000/s. There is no pre-scale on encoder.

I just want to know why FTM_QUAD_ENCODER count is related to pre-scale setting?

Thanks,

Christie

0 Kudos

498 Views
egoodii
Senior Contributor III

According to figure 44-3 of the reference manual KV5XP144M240RM.pdf, QD input DOES go thru the prescaler:

pastedImage_1.png

So you are seeing perfectly proper operation.

0 Kudos

498 Views
a8Chcx
Contributor V

Hi Earl,

Yes. I saw it on manual.

When you check the page 1216 for quad mode, there is no pre-scale, looks by-passed.

In the sample code, it is set to pre-scale=32 that is not right either. In sample, the filter value is set to 16. It should be wrong as well because range is 0~~15.

I just want to confirm if it is done in this way on purpose because I used MC56F8367, FTM QUAD is not related to pre-scale...

Thanks,

Christie

0 Kudos

498 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Please refer the 'Figure 44-3. FTM block diagram' in KV5XP144M240RM.

FTM block diagram.png

The FTM counter clock is the selected clock divided by the prescaler.

Prescaler.png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

498 Views
egoodii
Senior Contributor III

I don't know what you mean by 'on purpose' in this context.  The hardware 'does what it does'; I see what you mean about Fig.44-91, it is 'a pity' the documentation writer elected to 'lump' prescaler functions within the 'FTM counter' functional block, but your own experiments confirm 'it is in the path'.  The fact a completely different family of parts works differently is not surprising.

I agree it seems a 'poor default' for a prescaler of 32, MOST applications of quadrature input need every edge they can see.  I can't comment on the 'filter value', as I don't know how the 'supplied value' is adapted into a 'register value' --- you can certainly look in your debugger and 'see what you get' from 16 (or try to follow the driver code!).

0 Kudos