【tina_nezha】【求助】pwm无法启用/或寻其他途径控制舵机
-
我尝试使用字符驱动和/sys/class/pwm/pwmchip0/export 启用pwm,驱动和用户层操作都是类似下面这种错误pinctrl_get failed
[ 868.035098] platform 2000c17.pwm7: pinctrl_get failed
这是/sys/class下的pwm7(pwm1也是如此)
root@TinaLinux:/sys/devices/platform/soc@3000000/2000c00.pwm/pwm/pwmchip0/pwm7# ls capture output_type power duty_cycle period uevent enable polarity waiting_for_supplier root@TinaLinux:/sys/devices/platform/soc@3000000/2000c00.pwm/pwm/pwmchip0/pwm7# echo 2000000 >period root@TinaLinux:/sys/devices/platform/soc@3000000/2000c00.pwm/pwm/pwmchip0/pwm7# echo 1000000 >duty_cycle root@TinaLinux:/sys/devices/platform/soc@3000000/2000c00.pwm/pwm/pwmchip0/pwm7# echo normal >polarity root@TinaLinux:/sys/devices/platform/soc@3000000/2000c00.pwm/pwm/pwmchip0/pwm7# echo 1 > enable [ 868.035098] platform 2000c17.pwm7: pinctrl_get failed ash: write error: No such device root@TinaLinux:/sys/devices/platform/soc@3000000/2000c00.pwm/pwm/pwmchip0/pwm7# cat capture [ 885.724275] platform 2000c17.pwm7: pinctrl_get failed [ 885.730046] time out is 1000 [ 894.621166] platform 2000c17.pwm7: pinctrl_get failed [ 894.627001] sunxi_pwm_capture: pwm capture timeout ! [ 894.632728] platform 2000c17.pwm7: pinctrl_get failed [ 894.638491] time out is 1000 [ 903.529004] platform 2000c17.pwm7: pinctrl_get failed [ 903.534865] sunxi_pwm_capture: pwm capture timeout ! cat: read error: Operation not permitted root@TinaLinux:/sys/devices/platform/soc@3000000/2000c00.pwm/pwm/pwmchip0/pwm7# cat /sys/kernel/debug/pwm platform/2000c00.pwm, 8 PWM devices pwm-0 (vdd-cpu ): requested period: 0 ns duty: 0 ns polarity: inverse pwm-1 (sysfs ): requested period: 2000000 ns duty: 0 ns polarity: inverse pwm-2 (lcd ): requested enabled period: 1000000 ns duty: 390625 ns polarity: normal pwm-3 ((null) ): period: 0 ns duty: 0 ns polarity: inverse pwm-4 ((null) ): period: 0 ns duty: 0 ns polarity: inverse pwm-5 ((null) ): period: 0 ns duty: 0 ns polarity: inverse pwm-6 ((null) ): period: 0 ns duty: 0 ns polarity: inverse pwm-7 (sysfs ): requested period: 2000000 ns duty: 1000000 ns polarity: normal root@TinaLinux:/sys/devices/platform/soc@3000000/2000c00.pwm/pwm/pwmchip0/pwm7#
下面是修改过的设备树
pwm1_pin_a: pwm1@0 { pins = "PB6"; // allwinner,muxsel = <5>;//这个地方尝试过,也是pinctrl_get failed function = "pwm1"; drive-strength = <10>; bias-pull-up; }; pwm1_pin_b: pwm1@1 { pins = "PB6"; function = "gpio_in"; }; &pwm1 { pinctrl-names = "active", "sleep"; pinctrl-0 = <&pwm1_pin_a>; pinctrl-1 = <&pwm1_pin_b>; status = "okay"; };
我还把设备树中PB6相关的其他设备都“disable”了(TWI3和daudio2)(i2s2的我没找到 )结果和上面相同
allwinner,muxsel = <5>;我试着加在了pwm1_pin_a: pwm1@0 {} 里,也没效果 -
刚刚用gpio_direction_output()和usleep模拟PWM。。不过只能控制舵机0°~160°左右,达不到180°。不知道为什么。。还在摸索
-
pwm7我记得在lcd绑定了
-
@yuzukitsuru 好像是的。pwm0、pwm2、pwm7,在board.dts里面配置了休眠和常规两种状态,然后也是默认启用的。
不过我自己添加的pwm1,也是这种情况。 -
pwm应该不是这样绑定pin的,具体看一下pwm的文档
-
@yuzukitsuru
我看了那个文档,不过估计是没有完全理解。
类似这种,默认定义了0~7号pwm
然后在板级dts里只配置了pwm0 pwm2 pwm7
其他的写都没写。看样子是要自己添加。但是没有看到介绍如何添加。然后,提供的内核api需要 pwm号, 返回的错误信息在前面(和/sys/class/pwm下的信息一样)
-
@yuzukitsuru 在 【tina_nezha】【求助】pwm无法启用/或寻其他途径控制舵机 中说:
pwm应该不是这样绑定pin的,具体看一下pwm的文档
还有个问题,求大佬指条明路,之前询问控制DHT11,说道使用告诉I2C外设来实现。大佬,具体点,哪款芯片,或者哪一类呢
-
-
Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号