Disabling FTM

I am using one of the FTM timers in a K60 as a PWM signal to control the dimming of the backlighting on a display. It all works correctly but I am confused about the optimal way to disable the FTM and guarantee that the output of the FTM is low before entering one of the K60 sleep modes. I have tried a number of approaches but haven't come up with an optimal solution that works every time before sleep mode is entered. I hate to just throw in arbitrary delays without understanding the underlying considerations. I was hoping that stopping the clock and setting the initialization bit would work but it doesn't work reliably.

I am not sure how you implement your application, and which mode you put the FTM in, but generally the FTM will generate an interrupt when channel (n) match event happens, you may put the disable code in the ISR providing the time from channel (n) match to timer overflow is enough to run the ISR code.BTW, you may try FTMx_OUTMASK register if the inactive state is low in your case.

I also tried changing the pin MUX to GPIO, but after stopping the FTM clock rather than before. Neither way worked without delays.

I am not using the interrupt capability in the FTM. Using the OUTMASK register I would assume would also need a delay since it is buffered.

I have come up with a workable solution by setting the offset ticks equal to the period, waiting for 20 msec, and then stopping the clock. I don't know whether 20 msec is optimal, but I do know that 2 msec wasn't enough. I still don't know why setting the init bit in the MODE register doesn't work - but maybe that too requires a delay.

Ok, I think I am better understanding the issue. I do have an external pulldown on the pin - but the value is 200k - not what I would normally choose but that was the value recommended by the backlight driver manufacturer.

So, I just enabled the internal pulldown on the pin (which reduces the effective resistance) and now both the solution suggested by Mark and XiangJun work correctly without added delays which was what I was wanting.