Quadrature Decoder not Work with FTM2 Interrupt Handler

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Quadrature Decoder not Work with FTM2 Interrupt Handler

1,189件の閲覧回数
haoqin
Contributor I

Hello Nxp Team,

 

I used S32K144 controller in our project. I want to use quadrature decoder pin to PTD10 and PTD11 from two channel encoder. if I set:

PORTD->PCR[10] = PORT_PCR_MUX(3); // Set PTD10 for FTM2 - Phase B input
PORTD->PCR[11] = PORT_PCR_MUX(3); // Set PTD11 for FTM2 - Phase A input

and enable to QUADEN = 1, the interrupt handler FTM2_Ch0_Ch1_IRQHandler() doesn't work. Does quadrature decoder mode supports interrupt or not? If supported, what do I set wrong? Thank you.

Best regard,

Howard

ラベル(1)
0 件の賞賛
返信
3 返答(返信)

1,043件の閲覧回数
dianabatrlova
NXP TechSupport
NXP TechSupport

Hello,

The interrupt should works. Please refer to the diagram below.

Did you check if FTM counter works?

How have you set the channel 0 and channel 1?

pastedImage_2.png

I hope it helps.

Best Regards,

Diana

0 件の賞賛
返信

1,043件の閲覧回数
haoqin
Contributor I

Thanks for reply Diana,

I set FTM2 as quadrature decoder mode as below:

FSL_NVIC->ISER[111 / 32] |= (1 << (111 % 32));
/* Encoder simulated with totally 36 rising/falling edges */
FTM2->MOD = FTM_MOD_MOD(36);
FTM2->CNTIN = FTM_CNTIN_INIT(0);
FTM2->QDCTRL= FTM_QDCTRL_QUADEN_MASK;
FTM2->CNT = 0;
/* Select clock */
FTM2->SC = FTM_SC_CLKS(1) | FTM_SC_TOIE_MASK;

void FTM2_Ch0_Ch1_IRQHandler()//this interrupt is shared by ch0&1
{
PTC->PTOR |= 1<<9; // Toggle
FTM2->SC &= ~FTM_SC_TOF_MASK;
Hall_AB_Angle = FTM2->CNT;
}

I cannot saw a toggle wave on my oscilloscope from pin C9. I guess interrupt didn't work.

Can you let me know what is wrong in my settings?

Thank you.

Hao

0 件の賞賛
返信

1,043件の閲覧回数
dianabatrlova
NXP TechSupport
NXP TechSupport

Hello Hao,

According to our previous discussion in the service ticket, I would like to add a comment here.

"The quadrature decoder mode uses the input signals phase A and B to control the FTM counter increment and decrement."

Your interrupt (FTM2_Ch0_Ch1_IRQHandler()) does not work because you did not configure FTM2 ch0/ch1.

Then what should cause interrupt according to you, interrupt on position count?

Thank you.

Best Regards,

Diana

0 件の賞賛
返信