i.MX6UL -- PWM用户空间使用方法【转】

本文转载自:https://blog.csdn.net/u014486599/article/details/53010114

i.MX6UL -- PWM用户空间使用方法



    开发平台: 珠海鼎芯D518--基于i.MX6UL

    开发系统: Linux4.1.15

    文件系统:Yocto-Busybox1.23



    基于iMX的PWM使用方法,这里将以PWM2作为示例,以下为PWM部分设置示例及解析:

root@imx6ulevk:~# cat /sys/kernel/debug/pwm/*查看当前PWM设备 */

platform/20fc000.pwm, 1 PWM device

 pwm-0   ((null)              ):

platform/20f8000.pwm, 1 PWM device

 pwm-0   ((null)              ):

platform/20f4000.pwm, 1 PWM device

 pwm-0   ((null)              ):

platform/20f0000.pwm, 1 PWM device

 pwm-0   ((null)              ):

platform/208c000.pwm, 1 PWM device

 pwm-0   ((null)              ):

platform/2088000.pwm, 1 PWM device

 pwm-0   ((null)              ):

platform/2084000.pwm, 1 PWM device

 pwm-0   ((null)              ):

platform/2080000.pwm, 1 PWM device

 pwm-0   (backlight           ): requested enabled

root@imx6ulevk:~#echo 0 >/sys/class/pwm/pwmchip1/export/*设置PWM输出,调出pwm0目录下设备节点,用于以下配置 */


root@imx6ulevk:~# cat /sys/kernel/debug/pwm

platform/20fc000.pwm, 1 PWM device

 pwm-0   ((null)              ):

platform/20f8000.pwm, 1 PWM device

 pwm-0   ((null)              ):

platform/20f4000.pwm, 1 PWM device

 pwm-0   ((null)              ):

platform/20f0000.pwm, 1 PWM device

 pwm-0   ((null)              ):

platform/208c000.pwm, 1 PWM device

 pwm-0   ((null)              ):

platform/2088000.pwm, 1 PWM device

 pwm-0   ((null)              ):

platform/2084000.pwm, 1 PWM device

 pwm-0   (sysfs              ): requested enabled

platform/2080000.pwm, 1 PWM device

 pwm-0   (backlight           ): requested enabled


root@imx6ulevk:~#cat/sys/class/pwm/pwmchip1/pwm0/{enable,period,duty_cycle}/*查看PWM使能、一个周期时间、一个周期中ON时间 */

0

0

0

root@imx6ulevk:~#echo 1 >/sys/class/pwm/pwmchip1/pwm0/enable/*设置PWM2使能 */

root@imx6ulevk:~#echo 1000000 >/sys/class/pwm/pwmchip1/pwm0/period/*设置PWM2一个周期的持续时间,单位为ns,即1K Hz */

root@imx6ulevk:~#echo 500000 >/sys/class/pwm/pwmchip1/pwm0/duty_cycle/*设置一个周期中的”ON”时间,单位为ns,即占空比=duty_cycle/period=50% */

root@imx6ulevk:~#cat/sys/class/pwm/pwmchip1/pwm0/{enable,period,duty_cycle}

1

1000000

500000

posted @ 2019-01-15 17:43  请给我倒杯茶  阅读(696)  评论(0编辑  收藏  举报