Adafruit Industries, Essential service and business: NYC – Executive Order 202.6 - Read more.
0

PWM introspection and PWM.stop() in the Python library
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

PWM introspection and PWM.stop() in the Python library

by jstoner on Wed Jun 15, 2016 12:03 pm

Is there a way (besides connecting a PWM to a GPIO input) to check the current state of a PWM pin?

I am trying to make sure that when I call PWM.stop() I leave the pin in an off state. Experimentally I am finding that if I stop PWM on a pin when it's in the on state it is left in the on state, which is not good for my application. (I think. Do I have that right?)

I could connect to a GPIO and turn off on a wait_for_edge(GPIO.FALLING) event, but I wanted to check first if there is a way to introspect on the state of a PWM pin without changing wiring.

I don't see a wait_for_edge() function on PWM. I don't see another way to read current state on a PWM in /sys/devices/ocp.*.

jstoner
 
Posts: 22
Joined: Tue Dec 11, 2012 11:10 pm

Re: PWM introspection and PWM.stop() in the Python library

by drewfustini on Wed Jun 22, 2016 1:45 am

These files in /sys might be of use:
/sys/kernel/debug/pwm
platform/48304100.ecap, 1 PWM device
pwm-0 ((null) ):

platform/48304200.ehrpwm, 2 PWM devices
pwm-0 ((null) ):
pwm-1 ((null) ):

platform/48302200.ehrpwm, 2 PWM devices
pwm-0 (PWM_P9_14 ): requested enabled
pwm-1 ((null) ):

platform/48300100.ecap, 1 PWM device
pwm-0 ((null) ):

platform/48300200.ehrpwm, 2 PWM devices
pwm-0 ((null) ):
pwm-1 ((null) ):


/sys/kernel/debug/pinctrl/44e10800.pinmux/pingroups
group: pinmux_pwm_P9_14_pins
pin 18 (44e10848)


/sys/kernel/debug/pinctrl/44e10800.pinmux/pinmux-pins
pin 18 (44e10848): pwm_test_P9_14.11 (GPIO UNCLAIMED) function pinmux_pwm_P9_14_pins group pinmux_pwm_P9_14_pins


/sys/devices/ocp.3/pwm_test_P9_14.11/duty
/sys/devices/ocp.3/pwm_test_P9_14.11/period
/sys/devices/ocp.3/pwm_test_P9_14.11/polarity

drewfustini
 
Posts: 920
Joined: Sat Dec 26, 2015 1:19 pm

Re: PWM introspection and PWM.stop() in the Python library

by jstoner on Wed Jun 22, 2016 11:29 am

From those I can determine if PWM function is active on a pin.

Poking around I don't see how to determine if the PWM function has turned the current from the pin on or off at that moment. I guess I can just connect back to a GPIO in and wait on falling or rising events.

jstoner
 
Posts: 22
Joined: Tue Dec 11, 2012 11:10 pm

Please be positive and constructive with your questions and comments.