I even back peddled to a 2015 release on a 4.x kernel, found the overlays in lib/firmware and applied them. It still did not work, has any one had any luck with getting hardware pwm up?
if memory serves, i used the PWM to control a servo motor, many years ago.
We were going to use it as an endpoint device. Just could not get the Tegraās hardware PWM cleaned up enough so my thoughts were to make bbb a child and gather data and control some stuff then let the GPU of the parent make the decisions.
I was hoping to get an old version up so I can find some direction, it helps when you have something to copy off of.
PWM works straight forward, like any other output:
PWM
Generating a Pulse Width Modulated output is available by the PwmMod member functions (in IO and RB mode). Therefor libpruio uses different subsystems: the PWM modules and the CAP modules in the PWMSS subsystems, as well as the TIMER [4-7] subsystems. All modules are supported in a transparent API. See section PWM for further info.
Function PwmMod::setValue() sets the frequncy and duty cycle (and configure the pin, if necessary).
Function CapMod::Value() gets the current frequency and/or duty cycle (they may differ from the required values).
Furthermore advanced features of the PWMSS subsystems can be used by direct access to the register configuration and PRU interface, ie. syncronizing multiple PWM outputs (experts only).
Up to 13 lines can get used simultanously on BBB.
Regards
Thank you for sharing that. I will look into that. What overlay did you load to get that to output?
The uio-pruss driver overlay.
check this post : Help with Device Tree, Trying to expose kernel pps - #28 by gomer
It did not need any overlayā¦
good luck,
gomer
What is the config-pin for ?
501 config-pin -q P9.22
502 config-pin -a P9.22 pwm
503 config-pin -q P9.22
504 cd /sys/class/pwm
505 ls
506 echo 0 > pwmchip1/export
507 ls
508 cd pwm-1:0
509 ls
510 cat *
511 sudo sh -c āecho 1000000000 > periodā
512 sudo sh -c āecho 100000000 > duty_cycleā
513 sudo sh -c āecho 1 > enableā
I was using arago but uboot is not set up for loading an overlay so I went back to the official debain IoT image for testing the overlay. Everything is now exposed so now the focus is on getting the clocks configured properly and not breaking i2c upon boot.
debian@WS2812B:~/demo$ which config-pin
/usr/bin/config-pin
debian@WS2812B:~/demo$ uname -a
Linux WS2812B 4.14.71-ti-r80 #1 SMP PREEMPT Fri Oct 5 23:50:11 UTC 2018 armv7l GNU/Linux
debian@WS2812B:~/demo$
you said BBB right? not the BBAI which does not have config-pin. I believe that it is stockā¦
debian@WS2812B:~/demo$ config-pin help
config-pin [-a]
Set to , configuring pin multiplexing and optionally
configuring the gpio. Valid strings vary based on ,
however all pins have a default and gpio mode. The default mode is
the reset state of the pin, with the pin mux set to gpio, the pull
up/down resistor set to itās reset value, and the pin receive buffer
enabled. To setup gpio, the following strings are all valid:
gpio :
Set pinmux to gpio, existing direction and value unchanged
in | input:
Set pinmux to gpio and set gpio direction to input
out | output :
Set pinmux to gpio and set gpio direction to output
hi | high | 1 :
Set pinmux to gpio and set gpio direction to output driving high
lo | low | 0 :
Set pinmux to gpio and set gpio direction to output driving low
To enable pull-up or pull-down resistors, a suffex may be appended to
any of the above gpio modes. Use + or _pu to enable the pull-up resistor
and - or _pd to enable the pull-down resistor. Examples:
in+ | in_pu:
Enable pull-up resistor and setup pin as per input, above.
hi- | hi_pd:
Enable pull-down resistor and setup pin as per high, above.
While the pull-down resistor will be enabled, it will not do much
until application software changes the pin direction to input.
config-pin -l
list valid values for
config-pin -i
show information to
config-pin -q
query pin and report configuration details
config-pin -f [file]
Read list of pin configurations from file, one per line
Comments and white-space are allowed
With no file, or when file is -, read standard input.
config-pin -h
Display this help text
Iāve found that config-pin works great on the BBBā¦ let me know if you need more help
good luck
gomer
Thank you, what image are you using?
This is for bbb.
my last post didnāt render perfectlyā¦ If you have /usr/bin/config-pin then do the config-pin help and study what might serve as a āmanā page.
if you do config-pin -i P9_22 it should report that pwm is available for this pin ā¦ config-pin can be used to configure this pin for pwm ā¦
the rest of the history should be straight forward.
good luck
gomer
check if you have /usr/bin/config-pinā¦ the rest should be easy
gomer
Okay, I will try that one and see how it goes.
just curious whether you followed through, and how it worked.
gomer
Tried the older image and it did not work either.
Never did get the clock for the pwm module on the bbb to fire up, the devmem2 query to the pwm would create an error. Not sure if the SoC even has a hardware pwm on it, cannot find any solid evidence of those using it or a primitive example to demonstrate it. Plenty of others trying but have not found any thing substantial, some of those are going back to at least 2015ā¦ I ordered a c2000 board with the tms320 and will see how that works out.
sad to hear thatā¦
let me tell you that I have eight BBB and have run pwm on all of them successfully. in fact, I have a project that has 3 pwm signals simultaneosly, never had a problemā¦
it is possible that your BBB is defective, but Iād say unlikely.
Iām willing to assist in running this down, but youād have to do most of the workā¦ first question: are you willing?
second question: do you have a oscilloscope to verify what is happening?
third question: at any point in the history that I posted does something not make sense?
fourth question: are you making it to the end of the example that I posted and just not being able to verify the signal?
are there others who are willing to verify the steps outlined in my post to give confidence that this process works?
gomer
I just tried the sequence of commands you linked to earlier. There were some minor differences, likely due to different OS version. Everything appeared to work perfectly, however the pin output remains at logic 0.
cat period duty-cycle
and enable
all report the values as written.
1: OS: Bullseye Minimal Image 2023-10-07
2: Command variations:
config-pin barfs on the -a
flag
replace cd pwm-1:0
with pwmchip1/pwm0
Paul
ābarfsā is not an industry term, is it? ā¦ could you be more specific?
is this meant to be verification? ā¦ what does your scope indicate?
even without a scope, if you put a led from P9.22 to ground, it should give you the blinkā¦ you might want to put a resistor in the circuit to limit current, but not necessary for short time ( i think )ā¦
thanks for helping.
gomer
GPIO Pin Configurator
Usage: config-pin -c <filename>
config-pin -l <pin>
config-pin -q <pin>
config-pin <pin> <mode>
My 'scope isnt handy just now. Tested with an led (with resistor) and various duty cycle values to help ensure the pulses are visible.
edit:
The list editor has isnt showing the first line of my message - it is the command:
config-pin -a P9.22 pwm