FTM_CNT value changing in quadrature encoder mode without any movement at the encoder end. Can somebody help intialize FTM in quadrature encoder mode with output compare match?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

FTM_CNT value changing in quadrature encoder mode without any movement at the encoder end. Can somebody help intialize FTM in quadrature encoder mode with output compare match?

433 次查看
tan_k
Contributor II

I am currently using colibri imx 7 som. I am trying to initialize the quadrature encoder mode with ouput compare match. The code given below the intialization of registers as per the instructions given in the manual. I do see change in the FTM count register even though the enoder is not moving. Are there any other changes I need to make to the FTM registers or any other registers in conjuntion to make the code functional

//initialization is mentioned on pg 4197

FTM_FMS=0x00000000; //6 WPEN 0 Write Protection Enable

FTM_MODE |=(1<<FTMEN); 

FTM_SC &= ~((1<<CLKS_0)|(1<<CLKS_1)); 

FTM_CONF |=(1<<BDMMODE_1)|(1<<BDMMODE_0);


FTM_POL=0x00000003;

FTM_OUTMASK =0x0000007A; 


FTM_QDCTRL &= ~((1<<QUADMODE)|(1<<QUADEN));

FTM_CNTIN=0x00000000;

FTM_C7SC=0x0000001C; 

FTM_COMBINE=0x00000000;

FTM_C7V=0x00006000; 


FTM_DEADTIME=0x00000000; 

FTM_FILTER=0x00000044;

// FTM_INVCTRL=0x00000000; //not used


//FTM_SWOCTRL=0x00000000; //not used

// FTM_OUTINIT=0x00000000; //not used


FTM_SC |=(1<<CLKS_0); 

FTM_QDCTRL |=(1<<PHBFLTREN)|(1<<PHAFLTREN)|(1<<QUADEN);


FTM_MODE &=~(1<<FTMEN);


FTM_SYNCONF |= (1<<SYNCMODE)|(1<<SWRSTCNT)|(1<<SWWRBUF)|(1<<SWOM); 


FTM_SYNC |= (1<<SWSYNC) |(1<<CNTMAX)|(1<<SYNCHOM) ;

FTM_CNT=0x00000000; //0-15 COUNT 0x000 Counter Value

标签 (1)
0 项奖励
0 回复数