Hi XiangJun Rong,
Thank you for your response! I got no problems with initialisation and work with QD exept i Cant write to FTM CNT register a value. I am using encoder with push button as a HMI. My INI-code. When timer overflows it goes to CNINiT and when underflow it goes to MOD-it is as predicted. But i want to have an FTM_CNT at a defined by software value at some moments, particulary in the beggining.
My code is:
//init QD on FTM1
SIM_SCGC6|=SIM_SCGC6_FTM1_MASK;
FTM1_MODE |= FTM_MODE_WPDIS_MASK;
FTM1_MODE |= FTM_MODE_FTMEN_MASK;
FTM1_CONF |= FTM_CONF_BDMMODE(3);
FTM1_MOD = 4500;
FTM_HAL_SetCounterInitVal(FTM1_BASE_PTR,2550);
FTM_HAL_SetSyncMode(FTM1,kFtmUseSoftwareTrig);
FTM1_QDCTRL |= FTM_QDCTRL_QUADEN_MASK;
FTM1_SC |= FTM_SC_CLKS(3);
FTM_HAL_SetClockPs(FTM1_BASE_PTR,kFtmDividedBy1);
FTM_HAL_SetQuadPhaseAPolarity(FTM1_BASE_PTR,1);
FTM_HAL_SetQuadPhaseBPolarity(FTM1_BASE_PTR,1);
And i had a hope that that code can do it:
FTM_HAL_SetCounter(FTM1,4000);
FTM_HAL_SetSoftwareTriggerCmd(FTM1,true);
Ofc. I can set up MOD=1 and CNINiT=0 and use interrupts to count my value using TOF and TOFDIR bits but it is not attractive solution since it uses my CPU more often.