AnsweredAssumed Answered

FTM Channel (n) Value (FTMx_CnV) issue

Question asked by Edward Karpicz on Mar 26, 2014
Latest reply on Apr 22, 2014 by Edward Karpicz

Hello,

It looks like writes to FTM channel timer compare value register (FTMx_CnV) are often ignored. I see it both reading compare register and observing pin output with o-scope.
I'm not sure if maskset 1N02G errata "e6165 FTM: FlexTimer external clock source cannot be faster than 20MHz" applies here. I'm using Fast OSC clock /2 clocking option (see Vybrid RM 9.10.3 FTM clocking). That's 12MHz. I further prescale it down by 1/128. What I see is that I need to loop writing FTMx_CnV about 40 times at 500MHz A5 core clock. Lowering FTM prescaler to 1/16 I need up to 6 write loop iterations.
If this is normal, then please point me to Vybrid RM where this is explained.

 

Thanks


Edward


P.S. Initialization and write-verify loop.


   // ungate Flextimer
   CCM->CCGR1 |= CCM_CCGR1_CG9(CCM_CCGR_BITS_ON_ALWAYS);

   // use "external" Fast OSC clock/2
   CCM->CSCMR2 = (CCM->CSCMR2 & CCM_CSCMR2_FTM1_EXT_CLK_SEL_MASK) | CCM_CSCMR2_FTM1_EXT_CLK_SEL(2);
   CCM->CSCDR1 |= CCM_CSCDR1_FTM1_CLK_EN_MASK;

   FTM1->SC =   (3<<3) // "ext" clock
             | 7;      // 1/128 divider

   FTM1->CONTROLS[TRIGCH].CnSC = 0x18; //output compare, set pin low on match
...

#define PulseWTicks 100
unsigned int newtv;
volatile int i;

   FTM1->CONTROLS[TRIGCH].CnSC &= ~FTM_CnSC_CHF_MASK; // clear flag

   newtv= FTM->CONTROLS[TRIGCH].CnV + PulseWTicks;
   newtv &= 0xFFFF;

   i = 0;
   do
   {
      FTM1->CONTROLS[TRIGCH].CnV = newtv;
      i++;
   }while(newtv != FTM->CONTROLS[TRIGCH].CnV);

Outcomes