您尚未登录。

楼主 # 2025-05-21 15:18:14

yozad
会员
注册时间: 2025-03-04
已发帖子: 3
积分: 18

求大佬,全志T507 PWM互补输出怎么配置?

全志T507,去掉了千兆网,把PI12、PI13复用为PWM2、PWM3,想要让PWM2、3互补输出。

在源码pwm_sunxi_new里面看到可以将pwm配置成互补输出模式,手册上也说可以配置成互补输出。

咨询飞凌他们没玩过互补输出。

看源码需要在设备树里面配置"bind_pwm"和"dead_time",获取死区时间和“互补输出绑定的pwm??”,这里的bind_pwm不是很理解。

static int sunxi_pwm_get_config(struct platform_device *pdev, struct sunxi_pwm_config *config)
{
	struct device_node *np = pdev->dev.of_node;
	int ret = 0;

	/* read register config */
	pr_info("sunxi_pwm_get_config %s\n", np->name);

	ret = of_property_read_u32(np, "bind_pwm", &config->bind_pwm);
	if (ret < 0) {
		/*if there is no bind pwm,set 255, dual pwm invalid!*/
		config->bind_pwm = 255;
		ret = 0;
	}

	ret = of_property_read_u32(np, "dead_time", &config->dead_time);
	if (ret < 0) {
		/*if there is  bind pwm, but not set dead time,set bind pwm 255,dual pwm invalid!*/
		config->bind_pwm = 255;
		ret = 0;
	}

	pr_info("bind_pwm=%d,dead_time=%d\n", config->bind_pwm, config->dead_time);
	ret = of_property_read_u32(np, "clk_bypass_output", &config->clk_bypass_output);
	if (ret < 0) {
		/*if use pwm as the internal clock source!*/
		config->clk_bypass_output = 0;
		ret = 0;
	}

	of_node_put(np);

	return ret;
}

修改设备树,增加"bind_pwm"和"dead_time"

pwm2: pwm2@0300a000 {
			pinctrl-names = "active", "sleep";
			pinctrl-0 = <&pwm2_pin_a>;
			pinctrl-1 = <&pwm2_pin_b>;
			bind_pwm = 2;
			dead_time = 1000;
			status = "okay";
		};

但是设备树配置了这两个之后编译失败

Error: arch/arm64/boot/dts/sunxi/CII-Common.dtsi:543.15-16 syntax error
FATAL ERROR: Unable to parse input tree
make[2]: *** [scripts/Makefile.lib:313: arch/arm64/boot/dts/sunxi/board.dtb] Error 1
make[1]: *** [scripts/Makefile.build:648: arch/arm64/boot/dts/sunxi] Error 2
make: *** [arch/arm64/Makefile:153: dtbs] Error 2
make: *** Waiting for unfinished jobs....
  CHK     kernel/config_data.h
ERROR: build kernel Failed
INFO: mkkernel failed

有大佬玩过PWM的互补输出吗?怎么才能互补输出?

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn