AnsweredAssumed Answered

Issues with use of PWM on Kinetis K40

Question asked by stan chime on May 28, 2012
Latest reply on May 29, 2012 by Konrad Anton

I have been using a PWM to power a light, switching off the pwm when the light needs to be off.

I found that using FTM2 module with output on PORTA_PCR10, I have a problem switching off the pwm and leaving the output in a known state. Sometimes it works sometimes it does not. The issue ***appears*** to be mainly present when using the debugger and not in standalone code.

Has anyone any idea what the source of the issue is? My main concern is that there might be a conflict between the trace_d0 output on the same pin (although I de-selected it). Its the only correlation I could think of between the debugger and the issue.

If another pin would be better I may have to change the hardware (yuk..)


all input appreciated,


this is part of the init code:

/* added polarity set register for inactive state*/
  FTM2_POL = (uint32_t) 0x01UL;


The following code is used to switch off the light:


  /*force output to inactive state*/
   FTM2_OUTMASK = 1;
  /*shut off counter (set source to none)*/
   FTM2_SC &= ~((uint32_t)0x10UL);

      /*  removed - was not effective
       FTM2_MODE |= (uint32_t)0x02UL;
       FTM2_MODE |= (uint32_t)0x02UL;*/