cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

Anonymous
Not applicable

Anyone have a good example (source and HW set-up) of using a PWM in a 1 shot configuration and changing the pulse width value. creater 3 environment.

0 Likes
Reply
9 Replies
Anonymous
Not applicable

Creator 3?

0 Likes
Reply
Esteemed Contributor

Actually quite simple, place on schematic, double click,

   

and config, trigger can be single trigger or multiple trigger.

   

The just start up with API and give it the trigger. Reset after

   

event, or other possibilities via interrupt.

   

 

   

0 Likes
Reply
Esteemed Contributor II

Probably you are using Creator 2.2 and a PSoC3.

   

Set the trigger in the "Advanced" configuration tab to "multi-trigger" . While the PWM is waiting for a trigger pulse you may set the pulse-width with the API WriteCompare() to any value within the given limit.

   

 

   

Bob

0 Likes
Reply
Anonymous
Not applicable

OK

   

The multiple trigger is not quite giving me what I want, but I have more basic question.

   

How does the 3 of these interact?

   

   

PWM_1_WriteCounter(19);

   

PWM_1_WritePeriod(counterValue);

PWM_1_WriteCompare(2);

   

   

With the multitrigger setup you suggested, I'm finally able to vary the distance between pulses by setting the period value, but get many of them. I suspect there are knob setting to just get one, but I'm still tinkering to find the right combination.

   

What I'm after is simply to vary the width of the pulse, one time.

0 Likes
Reply
Esteemed Contributor II
        The pulsewidth is set with PWM_WriteCompare(). Bob   
0 Likes
Reply
Honored Contributor II
        
  • WritePeriod() sets the length of the complete PWM period (the maximum counter value - with normal PWM, it therefore sets the PWM frequency)
  •     
  • WriteCompare() sets the counter value when the PWM output changes from high to low (so it sets the duty cycle)
  •     
  • WriteCounter() sets the current counter value, so it influences when the next compare event happens (by going either forward or backward in the PWM timespace)
  •    
   

When using the multi-trigger mode, the next trigger event will only be start a new cycle after a complete PWM period has been completed (in the component data sheet, look at page 32ff).

0 Likes
Reply
Anonymous
Not applicable

This is what I ended up with (just the schematic loaded).

   

comments...

0 Likes
Reply
Honored Contributor II

No image to see here...

0 Likes
Reply
Esteemed Contributor

If you are trying to post an image, post as .BMP, and make it the last

   

thing you paste in the thread. I have found Firefox most of the time will

   

do this, whereas IE rarely.

   

 

   

Regards, Dana.

0 Likes
Reply