Quadrature Decoder not Work with FTM2 Interrupt Handler

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

Quadrature Decoder not Work with FTM2 Interrupt Handler

763 Views
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

Labels (1)
0 Kudos
3 Replies

617 Views
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 Kudos

617 Views
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 Kudos

617 Views
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 Kudos