全志平台Tina系统pwm控制led调试的方法(以R18某方案为例)

2024-02-02 14:56:15 浏览数 (1)

全志平台Tina系统pwm控制led调试的方法(以R18某方案为例)

sys_config.fe的修改:

--- a/recipes-bsp/tina-board/tulip-noma/configs/sys_config.fex  b/recipes-bsp/tina-board/tulip-noma/configs/sys_config.fex @@ -534,11  534,11 @@ pwm_positive        = port:PD22<2><0><default><default>  [pwm0_suspend]  pwm_positive        = port:PD22<7><0><default><default> -[pwm16]

-s_pwm0_used         = 0 [spwm0] spwm0_used           = 1  pwm_positive        = port:PL10<2><0><default><default> -[pwm16_suspend] [spwm0_suspend]  pwm_positive        = port:PL10<7><0><default><default>

        这个LED设计的是MUTE功能开启的时候点亮,所以要先把MUTE打开,调试的时候请先拉高PD4:

root@tulip-mozart:/sys/kernel# mount -t debugfs none debug/

root@tulip-mozart:/sys/kernel/debug/sunxi_pinctrl# echo pio > dev_name

root@tulip-mozart:/sys/kernel/debug/sunxi_pinctrl# echo PD4 > sunxi_pin

root@tulip-mozart:/sys/kernel/debug/sunxi_pinctrl# echo PD4 1 > data 

然后

echo 0 > /sys/class/pwm/pwmchip16/export

echo 100000 > /sys/class/pwm/pwmchip16/pwm0/period

echo 20000 > /sys/class/pwm/pwmchip16/pwm0/duty_cycle

echo 1 > /sys/class/pwm/pwmchip16/pwm0/enable

echo 80000 > /sys/class/pwm/pwmchip16/pwm0/duty_cycle

duty_cycle的值限制在0~period的范围内

period是周期,单位是ns。

如果要设置为某频率,比如如果频率想改成200Hz,

1/200Hz=0.005s=5 000 000 ns

这里就要改成5 000 000

然后在这个范围内变化,可以写个3000000什么的进行调试:

echo 0 > /sys/class/pwm/pwmchip16/export

echo 5000000 > /sys/class/pwm/pwmchip16/pwm0/period

echo 3000000 > /sys/class/pwm/pwmchip16/pwm0/duty_cycle

0 人点赞