Correct way of using PWM on GPIO-pins?

Hi!

Whats the typical / correct way to do PWM on GPIO-pins?

Now I’m doing:

  • Find memory address for pin, by looking in tegra19x-mb1-pinmux-p3668-a01.cfg
  • Example: PN.01 / GPIO13 / SOC_GPIO54 | 0x02440020
  • Use setting that I get from using the pinmux excel-sheet, which I have to start a computer with Microsoft Office to be able to run - then mangle it trough the pinmux-dts2cfg.py python script.
  • Set this value with devmem:
#pinmux.0x02440020 = 0x00000406; # soc_gpio54_pn1: gp, pull-down, tristate-disable, input-disable, lpdr-disable
sudo busybox devmem 0x02440020 32 0x406
  • Set the PWM values I want to use:
sudo sh -c "echo 0 > /sys/class/pwm/pwmchip0/export"
sudo sh -c "echo 10000 > /sys/class/pwm/pwmchip0/pwm0/period"
sudo sh -c "echo 2500 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle"
sudo sh -c "echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable"

I understand that I can change the .cfg and reflash the board, but that’s even more cumbersome.

Is there really no easier way to do this?
Would be great if the correct pinmux was set when using the sysfs export function, or similar.

Please enlighten me!

hello andreas.gustafsson,

ya, that’s correct process to update the pinmux.

this pin, GPIO13 is by default defined as GPIO. so, you’ll need to modify the pinmux spreadsheets and changing it as SFIO, i.e. GP_PWM1.
due to it’s mb1 configure file for pin settings, it a must to perform full-flash to update the cfg file.