FTM2 PTA10 will output different PWM waveform under FTM2_MOD=249

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

FTM2 PTA10 will output different PWM waveform under FTM2_MOD=249

660 Views
hansonhe
NXP Employee
NXP Employee

Dear, we test MK20DX256VLQ10, use FTM2 PTA10 output PWM, and find that when FTM2 mode work at 246 or 247 or 248, 250, 251,252, the PWM will continue output, but find when FTM2_MOD is 249, the PWM output is discontinuous.

 

System clock: 100M, Bus clock:50M. External crystal is 25Mhz.

 

Below is the test code, and also attached the test project under KDS IDE.

  /* SIM_SCGC3: FTM2=1 */
  SIM_SCGC3 |= SIM_SCGC3_FTM2_MASK; 
  FTM2_MODE = (FTM_MODE_FAULTM(0x00) | FTM_MODE_WPDIS_MASK); /* Set up mode register */
  FTM2_SC = (FTM_SC_CLKS(0x00) | FTM_SC_PS(0x00)); /* Clear status and control register */
  /* FTM2_CNTIN: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,INIT=0 */
  FTM2_CNTIN = FTM_CNTIN_INIT(0x00);   /* Clear counter initial register */
  /* FTM2_CNT: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,COUNT=0 */
  FTM2_CNT = FTM_CNT_COUNT(0x00);      /* Reset counter register */
  /* FTM2_C0SC: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,CHF=0,CHIE=0,MSB=0,MSA=0,ELSB=0,ELSA=0,??=0,DMA=0 */
  FTM2_C0SC = 0x00U;                   /* Clear channel status and control register */
  /* FTM2_C1SC: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,CHF=0,CHIE=0,MSB=0,MSA=0,ELSB=0,ELSA=0,??=0,DMA=0 */
  FTM2_C1SC = 0x00U;                   /* Clear channel status and control register */
  /* FTM2_MOD: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,MOD=0xFFFF */
  FTM2_MOD = 249;//250;//FTM_MOD_MOD(0xFFFF);      /* Set up modulo register */
  /* FTM2_C0SC: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,CHF=0,CHIE=0,MSB=1,MSA=0,ELSB=1,ELSA=1,??=0,DMA=0 */
  FTM2_C0SC = (FTM_CnSC_MSB_MASK | FTM_CnSC_ELSB_MASK | FTM_CnSC_ELSA_MASK); /* Set up channel status and control register */
  /* FTM2_C0V: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,VAL=0x30D4 */
  FTM2_C0V = 125;//FTM_CnV_VAL(0x30D4);      /* Set up channel value register */
  /* PORTA_PCR10: ISF=0,MUX=3 */
  PORTA_PCR10 = (uint32_t)((PORTA_PCR10 & (uint32_t)~(uint32_t)(
                 PORT_PCR_ISF_MASK |
                 PORT_PCR_MUX(0x04)
                )) | (uint32_t)(
                 PORT_PCR_MUX(0x03)
                ));
  /* FTM2_SC: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,TOF=0,TOIE=0,CPWMS=0,CLKS=1,PS=2 */
  FTM2_SC = (FTM_SC_CLKS(0x01) | FTM_SC_PS(0x02)); /* Set up status and control register */

Labels (1)
0 Kudos
2 Replies

357 Views
cutworth
NXP Employee
NXP Employee

Hi Hanson,

I have checked customer KDS project. Looks like they are not configuring FTM in PWM mode, instead they configure it in output compare mode and set output on match. Please double check what they wanted.

pastedImage_1.png

Also you can let customer try running the same configuration by change the output pin to other FTM output pin and if they see the same behavior. 

Hao

0 Kudos

357 Views
cutworth
NXP Employee
NXP Employee

Hi Hanson,

I have tried to add the PE generated code into one KSDK2.0 project for checking FTM function customer intended to use. But I did not find the problem you mentioned that when MOD=249, PWM output is discontinuous. Also I noticed with generated PE code, it's actually configured in edge-aligned PWM.

Do you have waveform measured to show the issue when MOD=249?

Hao 

0 Kudos