How to make sure that pin is set to low when PWM is disabled on KL25?

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

How to make sure that pin is set to low when PWM is disabled on KL25?

912 Views
quevedo
Contributor V

Hello,

I am working on a project where I have to turn an oscillator on and off, for an IR control. I am using the PWM_Enable() and PWM_Disable() functions from Processor Expert. However, the PWM component, on KL25, does not implement the ClrValue function. Is there any way for me to make sure that the pin is set to low when I disable PWM?

Thanks

0 Kudos
3 Replies

487 Views
quevedo
Contributor V

Hello,

After some tinkering, I think I solved the problem. First, I tried to create a GPIO_LDD component and share the pin with PWM. Thus, one could set output to low. It can be seen as the final comments on this blog post:

Tutorial: PWM with Processor Expert | MCU on Eclipse

Anyway, it was not working. In my project, I emulate an IR remote controller. Thus, I set up PWM to 38kHz, 33% duty cycle, and I use Enable() and Disable() functions on PWM component to control pulse generation, in time slices of 500us.

These slices are controlled by a periodic interrupt. When I stop sending the IR command, I disable the interrupt. Problem is, it may happen while PWM is on. So, I included a PWM Disable() command right after I disable the periodical interrupt.

Checking signals with a logic analyser, I found out that pin signal sometimes goes to 1. I wondered if when I disable PWM somehow the pin becomes an input, with an internal pull-up resistor. As the pin is switching a transistor, I placed a resistor between transistor base and GND. It seems that it did the job!

Any thoughts about the issue of the pin becoming an input when PWM is disabled?

0 Kudos

487 Views
Monica
Senior Contributor III

Antonio,

was that the solution? Please keep us posted :smileywink:

Best regards,

Monica

0 Kudos

487 Views
Paul_Tian
NXP Employee
NXP Employee

Hi, Antonio

It is not sure that the PWM output is low when you disable PWM random. I think you have to change to GPIO and output low before you disable PWM.

Hope my reply can help you.

Best Regards

Paul