Hanson He

FTM2 PTA10 will output different PWM waveform under FTM2_MOD=249

Discussion created by Hanson He Employee on Oct 18, 2016
Latest reply on Oct 24, 2016 by Cutworth Wang

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 */

Original Attachment has been moved to: MK20DX256.7z.zip

Outcomes