Disabling FTM

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

Disabling FTM

1,971 Views
ERussell
Contributor IV

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.

// Stop the clock

FTM0_SC = (FTM_SC_CLKS(0x00) | FTM_SC_PS(0x00));

// Set output initialization to be low

FTM0_OUTINIT &= ~FTM_OUTINIT_CH2OI_MASK;

// Force initialization

FTM0_MODE = FTM_MODE_FAULT(0x00) | FTM_MODE_WPDIS_MASK | FTM_MODE_INIT_MASK);

I've also tried resetting the count and setting the offset register to equal the period and using the SYNC register to force the buffer values to the registers but that didn't work either.

I would appreciate any help on this!

Thanks,

Elizabeth

0 Kudos
6 Replies

1,354 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Elizabeth,

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.

Hope that helps,


Have a great day,
Kan

Freescale Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,354 Views
ERussell
Contributor IV

Thanks to both of you who replied.

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.

Thanks again,

Elizabeth

0 Kudos

1,354 Views
mjbcswitzerland
Specialist V

Elizabeth

If you set the pin MUX it will 'immediately' set the pin to the idle state (the PWM will stil be running but not affecting the pin anymore).

In fact if you stop it to go to a sleep mode that automatically disables the FTM you don't even need to do anything else since it will freeze the PWM anyway.

Whe exiting sleep mode you just need to set the MUX back to FTM and it will continue from where it left off....

Regards

Mark

0 Kudos

1,354 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,Elizabath,

If you set the FTM_SC_CLKS(0x00), the FTM_CHx pin will be in high impedance, in the case, you have to connect a 5K~10K ohm pull-down resistor so that the FTM_CHx pin is in low logic.

Hope it can help you.

BR

XiangJun Rong

0 Kudos

1,354 Views
ERussell
Contributor IV

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.

I really appreciate the help!

Elizabeth

0 Kudos

1,354 Views
mjbcswitzerland
Specialist V

Elizabeth

I would change the pin MUX to GPIO (which is set to the inactive output state that you want).

Then disable the PWM operation (and optionally disable the clock to the FTM).

Then enter sleep mode.

This will immediately disable the output to its OFF state, freeze the PWM count and sleep.

On wake up you could easily continue from the frozen state by doing the reverse.

The transition will be (approx.) immediate.

Regards

Mark

0 Kudos