PWM Stop Output Condition

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I'm working with the CY8CKIT-059 5LP Prototyping Kit. I added a PWM in FF mode to my project and connect the output to the onboard Blue LED on P2.1. The PWM controls the LED as expected but when I'm done running the PWM I issue a PWM_Stop() followed by a LED_B_Write(0) (which LED_B is defined and connected to P2.1).

   

I would expect that after those 2 commands the LED would be OFF but it is ON. 

   

I'm not attaching my project as I thought this would be a general question with perhaps  something else I need to do to fully disconnect the PWM from the Blue LED. Reading the datasheet of the PWM it reads as though the stop state would be to have PWM at a 0 but perhaps I'm missing something.

   

Thanks,

   

George

0 Likes
8 Replies
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

You should issue a "kill" to the PWM to set its outputs to 0 before stopping it.

0 Likes
Anonymous
Not applicable

Do you have an example of doing this? I looked at the API and was expecting a "PWM_Kill()" command and there isn't. In FF mode there's only an asynchronous kill mode so I'm not sure how exactly to kill the PWM in code. While I'm asking, after you do kill the PWM is issuing a PWM_Start() enough to get it back up and running properly?

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Read the component data sheet, it explains the kill modes in detail. In a FF PWM you have a 'kill' input, when its '1' the output gets disabled (with the next clock cycle, independent of the current PWM state).

0 Likes
Anonymous
Not applicable

I have looked at the component datasheet and I see that in FF mode there is a kill input but I didn't see a register that can control the kill mode so what would you suggest I use to control the kill mode input?

0 Likes
lock attach
Attachments are accessible only for community members.
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

You can refer to this Code Example(as shown in image attached) available in PSoC Creator for help,in which a Control Register is being used for controlling Kill input of PWM component-

0 Likes
Anonymous
Not applicable

Thank you for your help. By following the PWM_Basic_test Example I was able to add the control register and force the PWM output low. It would be nice if this was just part of the API.

0 Likes
mape_1305036
Level 1
Level 1

This example seems to be not available anymore in PSoC Creator. Could anyone please share the code example?

Thanks

0 Likes
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

George,

There should be multiple ways to 'reset' your LED.

  • Use the kill input on the PWM as recommended by helic.
  • Stop the PWM and reset it.
  • Place a two-input AND gate between the output of the PWM and the output pin and use a Control Register to enable the LED.

pastedImage_1.png

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes