Hpwm single mode - interaction when resetting?

BCJKiwi

Senior Member
Project with 28X1

Currently using pwmout successfully but need another input so want to change the Pwmout to hpwm single mode on channel D to free up the input used by Pwmout.

Pwmout has the nifty pwmduty command which allows the duty to be changed without all the overhead of resetting the entire PWM device each time.

There are no code examples in the manual(2) for hpwm and the hpwm data sheet is not yet available.
Q1. Once hpwm is set up and running, does the entire command have to be used each time to change the Duty? Search has not found this discussed on Forum yet but then maybe I have not searched on the right topics.

Q2. What happens to the other 3 Hpwm ports each time the command is issued while these ports are doing other things?
i.e.
hpwmA is an input (push button for a mode selection)
hpwmB & C are driving leds (High/Low)

Current code snippet alternatives are;

original pwmout/pwmduty
Code:
' initialisation
pwmout 2,249,512    ' establish pwm pin, Period(frequency), Duty.
.
.
.
' in main loop
pwmduty 2,w1
hpwm
Code:
' initialisation
hpwm 0,0,%1000,249,512    ' mode(0=single),polarity(0=H),setting(%1000=D - Output4/Leg25), period(frequency), duty
.
.
.
' in main loop
hpwm 0,0,%1000,249,w1
Thanks
 

Technical

Technical Support
Staff member
1) you can use pwmduty here aswell (use 2 as the pin number - it doesn't matter if this is not the real pin number).
2) in single mode, if you have not masked in the other bits described, then they are not affected by hpwm, hence can be used for other tasks.
 

BCJKiwi

Senior Member
Thanks very much for the prompt reply.

I had considered trying pwmduty but dismissed the thought immediately assuming it wouldn't work!

Have just tested pwmduty and it works as you suggest.

Thanks again.
 

BCJKiwi

Senior Member
That would certainly make it clearer and promote its use!
Any ideas when the next 5.1.8 will be available - seems like it will have a lot of improvements.

Thanks
 
Top