Setting count of ftm quad decoder

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

Setting count of ftm quad decoder

612 Views
luimarma
Contributor III

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);

      }

   }

2 Replies

417 Views
luimarma
Contributor III

Happily it seems that I did not research strongly enough the answer can be found at Phillipp Reist post , thanks to him since never ever would have figured out.

Regards,

Luis

417 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Glad to know that your problem has been solved.

0 Kudos