AnsweredAssumed Answered

Cannot get quadrature decoder to work on K64F FTM2 using KSDK PEx/BM MQX

Question asked by dave408 on Mar 27, 2015
Latest reply on Mar 22, 2016 by dave408

I've been trying everything I can think of to get quadrature decoding to work with my FRDM-K64F board, running KDS 2.0, KSDK 1.1, MQX, and a combination of PEx and bare metal code.

 

I started by using the fsl_ftm component with the following settings:

 

 

 

 

 

 

 

 

 

 

 

With these settings, FTM2_CNT is always 0.

 

I have confirmed that the encoder works because I have my scope hooked up to PTB18 and PTB19 and can see the signals there.

 

I then found another post here on the forum that outlined the bare metal configuration.  So I changed my task code to configure FTM2 (perhaps it can't be done in a task?), and the results are the same.  Here is the code I used.  Note that I only modified registers where the already-set value by PEx looked reasonable.

 

void qd_task( task_param_t initial_data)

{

    static uint16_t counter = 0;

    uint32_t sim_scgc6 = SIM_SCGC6;

    uint32_t ftm2_mode = FTM2_MODE;

    FTM2_CONF |= FTM_CONF_BDMMODE(3);

    uint32_t ftm2_conf = FTM2_CONF;

    FTM2_MOD = 4095;

    uint32_t ftm2_mod = FTM2_MOD;

    uint32_t ftm2_cntin = FTM2_CNTIN;

    uint32_t ftm2_qdctrl = FTM2_QDCTRL;

    FTM2_SC |= 0x08; // use system clock

    uint32_t ftm2_sc = FTM2_SC;

 

    while(1) {

        if( FTM2_CNT != counter) {

            counter = FTM2_CNT;

        }

    }

}

 

After running up to the while loop, here are the register values:

 

sim_scgc6    uint32_t    0x64000001  

ftm2_mode    uint32_t    0x5  

ftm2_conf    uint32_t    0xc0  

ftm2_mod    uint32_t    0x0  

ftm2_cntin    uint32_t    0x0  

ftm2_qdctrl    uint32_t    0xcd  

ftm2_sc    uint32_t    0x9  

 

Can anyone suggest something for me to try to debug this further?

Original Attachment has been moved to: qd_pex_mqx.zip

Outcomes