PWM_A,PWM_B, PWM_C: how to control them?

  • Hi,

    I wish to control PWM_A, PWM_B and PWM_C on an armStoneA9r2, that, according to the GPIO reference card, are associated with /sys/class/gpio# 42, 125, 126 mapped on feature pins 28, 30, 32.


    On general linux forums, I've seen it should be possible to control PWM outputs by setting values on sysfs parameters such as duty_cycle, polarity, enable.

    But I can't find any of them on the sysfs treee on the pwm subfolder.


    On my board (among the others) the most likely entries I have are:

    /sys/class/pwm/pwmchip0/device/power/

    autosuspend_delay_ms

    control

    runtime_active_time

    runtime_status

    runtime_suspended_time


    But can't set any of those values, as I catch errors. (Permission denied).

    Looking in other paths under /sys/class/pwm/pwmchip# I've not found any suitable file I can set.

    am I missing something?


    Thanks and BR,

    Michele Bucceri

  • Hello Michele,


    to use the backlight via sysfs you will have to export it first.


    Go to the directory of the PWM you want to use
    cd /sys/class/pwm/pwmchip0/

    and export it

    echo 0 > export

    Please note that this will only work if this PWM is not claimed by another device like backlight.


    Now you should see a new subdirectory pwm0

    ls pwm0/


    There you shloud be able to set the period in nanosecond,

    echo 5000000 > pwm0/period

    the duty cycle in nanoseconds,

    echo 2500000 > pwm0/duty_cycle
    the polarity (this is only possible if the device is disabled),

    echo "inversed" > pwm0/polarity

    echo "normal" > pwm0/polarity

    and enable/disable the device.

    echo 1 > pwm0/enable

    echo 0 > pwm0/enable


    If you need an example on how to control pwm via a C-programm please see the pwm-example in your build directory of your release, e.g:

    fsimx6-B2020.04/build/examples-fus-B2020.04/pwm/pwm.c


    Best Regards


    Your F&S Support Team