AnsweredAssumed Answered

Setting count of ftm quad decoder

Question asked by Luis Martínez Martínez on Aug 31, 2018
Latest reply on Sep 12, 2018 by Robin_Shen

I am modifiying the FTM quad decoder example in order to change the quad decoder counter value to a fixed count different to the CNTIN value whenever a condition is given.

As explained in the documentation, whenever I try to modify the CNT value it resets to the CNTIN value, instead of changing to the given value.

I have tryed to overcome this problem changing the CNTIN value to the required value and then clearing the CNT value so it resets to the desired value, but I cannot get CINT value to sync to its new buffered value.

I have checked the documentation to find out how to sync it but I get really lost. I am using MCU Expresso SDK.

Any help will be appreciated.

 

The code looks something like this:

 

    FTM_GetDefaultConfig(&ftmInfo);
    ftmInfo.prescale = kFTM_Prescale_Divide_1;
    FTM_Init(QUAD_FTM_BASEADDR, &ftmInfo);

    /* Set the modulo values for Quad Decoder. */
    FTM_SetQuadDecoderModuloValue(QUAD_FTM_BASEADDR, 0U, DEMO_QUAD_DECODER_MODULO);

 

    /* Enable the Quad Decoder mode. */
    phaseParamsConfigStruct.enablePhaseFilter = true;
    phaseParamsConfigStruct.phaseFilterVal = 16;
    phaseParamsConfigStruct.phasePolarity = kFTM_QuadPhaseNormal;
    FTM_SetupQuadDecode(QUAD_FTM_BASEADDR, &phaseParamsConfigStruct, /* Phase A. */
                        &phaseParamsConfigStruct,                    /* Phase B. */
                        kFTM_QuadPhaseEncode);

   while (1) {

      if (flag) {

         FTM_SetQuadDecoderModuloValue(QUAD_FTM_BASEADDR, 300U, DEMO_QUAD_DECODER_MODULO);

         FTM_ClearQuadDecoderCounterValue(QUAD_FTM_BASEADDR);

         FTM_SetQuadDecoderModuloValue(QUAD_FTM_BASEADDR, 0U, DEMO_QUAD_DECODER_MODULO);

      }

   }

Outcomes