cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

New Contributor II

I would like to configure the pin to LOW whenever PWM is not active.

1. How can i do that?

2. How should i configure in PSOC the initial state? Initial Drive state LOW is disabled on PIN.

PWM and the PIN configuration: (issue in green circle)

pastedImage_0.pngpastedImage_1.pngpastedImage_2.png

0 Likes
Reply
1 Solution
Esteemed Contributor

Dear DimaSidi-san,

Thank you very much for your response.

I re-thought what was the problem with writing compare 0,

then realized that if the 0 is written during the cycle, which usually is,

it won't be applied till next PWM cycle.

Then I read the datasheet of PWM and wondered why we can not use "stop()"

according to the datasheet, stop also makes the signal to inactive state.

So I grabbed an Oscilloscope and gave a try.

Following pictures are

ch1 Yellow signal is PWM

ch2 Blue signal is TCPWM

ch3 magenta signal is enable(1) / disable(0) of PWM using each methods.

(1) using PWM_WriteCompare(0)

   As written above this is not a good choice for this purpose.

(2) using PWM_Stop()

  It works, but the transition from High to Low is rather slow.

So this may not be appropriate if you need immediate shut-off.

(3) using ControlReg with AND (Bob-san's method)

  Clearly the winner, sharp shut-off.

  But with a cost of a ControlReg and an AND gate, which should not be expensive though.

(1) Using PWM_WriteCompare(0) (and TCPWM_WriteCompare(0))

Using_Comp0.JPG

(2) Using PWM_Stop() (and TCPWM_Stop())

Using_Stop.JPG

(3) Using ControlReg and AND

Using_AND.JPG

Best Regards,

5-Feb-2019

Motoo Tanaka

View solution in original post

9 Replies
New Contributor II

I know this is not solving what you asked but you can also use the inverted output, you can configure that in the pwm tab. That would do the trick too

0 Likes
Reply
Esteemed Contributor II

You may use an AND gate and a control register to force the output low.

Bob

New Contributor II

Thanks,

Is there an example for the control register i can use?

0 Likes
Reply
Esteemed Contributor II

Which PSoC kit do you use? CY8CKIT-0??

Bob

0 Likes
Reply
New Contributor II

Hi,

I am using the CYBLE-224110-00

0 Likes
Reply
Esteemed Contributor II

Your device has got the required resources. See attached project.

Bob

Esteemed Contributor

Hi,

I'm just curious, but doesn't set compare to 0 do the same thing without any additional circuit?

    PWM_WriteCompare(0) ;

moto

0 Likes
Reply
New Contributor II

I remember reading in some post that this is not a good solution.

0 Likes
Reply
Esteemed Contributor

Dear DimaSidi-san,

Thank you very much for your response.

I re-thought what was the problem with writing compare 0,

then realized that if the 0 is written during the cycle, which usually is,

it won't be applied till next PWM cycle.

Then I read the datasheet of PWM and wondered why we can not use "stop()"

according to the datasheet, stop also makes the signal to inactive state.

So I grabbed an Oscilloscope and gave a try.

Following pictures are

ch1 Yellow signal is PWM

ch2 Blue signal is TCPWM

ch3 magenta signal is enable(1) / disable(0) of PWM using each methods.

(1) using PWM_WriteCompare(0)

   As written above this is not a good choice for this purpose.

(2) using PWM_Stop()

  It works, but the transition from High to Low is rather slow.

So this may not be appropriate if you need immediate shut-off.

(3) using ControlReg with AND (Bob-san's method)

  Clearly the winner, sharp shut-off.

  But with a cost of a ControlReg and an AND gate, which should not be expensive though.

(1) Using PWM_WriteCompare(0) (and TCPWM_WriteCompare(0))

Using_Comp0.JPG

(2) Using PWM_Stop() (and TCPWM_Stop())

Using_Stop.JPG

(3) Using ControlReg and AND

Using_AND.JPG

Best Regards,

5-Feb-2019

Motoo Tanaka

View solution in original post