如何正确配置 Beaglebone Black PWM

如何正确配置 Beaglebone Black PWM

我尝试过让 PWM 工作但没有成功。我正在使用TI 处理器 SDK与修改版本am335x-boneblack.dts设备树(见下文)

PWM 驱动程序 (erpwm1) 正确探测并出现在 中/sys/class/pwm/pwmchip0。然后,我配置了芯片

cd /sys/class/pwm/pwmchip0
echo 0 > export
echo 1000000 > pwm0/period
echo 250000 > pwm0/duty_cycle
echo 1 > pwm0/enable

但没有 PWM 输出。我错过了一些明显的东西吗?

这是我制作的设备树:

/dts-v1/;

#include "am33xx.dtsi"
#include "am335x-bone-common.dtsi"

/ {
    model = "TI AM335x BeagleBone Black";
    compatible = "ti,am335x-bone-black", "ti,am335x-bone", "ti,am33xx"; 
};

&ldo3_reg {
    regulator-min-microvolt = <1800000>;
    regulator-max-microvolt = <1800000>;
    regulator-always-on;
};

&mmc1 {
    vmmc-supply = <&vmmcsd_fixed>;
};

&mmc2 {
    vmmc-supply = <&vmmcsd_fixed>;
    pinctrl-names = "default";
    pinctrl-0 = <&emmc_pins>;
    bus-width = <8>;
    status = "okay";
};

&am33xx_pinmux {
    lcd_pins: lcd_pins {
        pinctrl-single,pins = <
            AM33XX_IOPAD(0x8a0, PIN_OUTPUT | MUX_MODE0) /* P9.45, lcd_data0 */
            AM33XX_IOPAD(0x8a4, PIN_OUTPUT | MUX_MODE0) /* P9.46, lcd_data1 */
            AM33XX_IOPAD(0x8a8, PIN_OUTPUT | MUX_MODE0) /* P9.43, lcd_data2 */
            AM33XX_IOPAD(0x8ac, PIN_OUTPUT | MUX_MODE0) /* P9.44, lcd_data3 */
            AM33XX_IOPAD(0x8b0, PIN_OUTPUT | MUX_MODE0) /* P9.41, lcd_data4 */
            AM33XX_IOPAD(0x8b4, PIN_OUTPUT | MUX_MODE0) /* P9.42, lcd_data5 */
            AM33XX_IOPAD(0x8b8, PIN_OUTPUT | MUX_MODE0) /* P9.39, lcd_data6 */
            AM33XX_IOPAD(0x8bc, PIN_OUTPUT | MUX_MODE0) /* P9.40, lcd_data7 */
            AM33XX_IOPAD(0x8c0, PIN_OUTPUT | MUX_MODE0) /* P9.37, lcd_data8 */
            AM33XX_IOPAD(0x8c4, PIN_OUTPUT | MUX_MODE0) /* P9.38, lcd_data9 */
            AM33XX_IOPAD(0x8c8, PIN_OUTPUT | MUX_MODE0) /* P9.36, lcd_data10 */
            AM33XX_IOPAD(0x8cc, PIN_OUTPUT | MUX_MODE0) /* P9.34, lcd_data11 */
            AM33XX_IOPAD(0x8d0, PIN_OUTPUT | MUX_MODE0) /* P9.35, lcd_data12 */
            AM33XX_IOPAD(0x8d4, PIN_OUTPUT | MUX_MODE0) /* P9.33, lcd_data13 */
            AM33XX_IOPAD(0x8d8, PIN_OUTPUT | MUX_MODE0) /* P9.31, lcd_data14 */
            AM33XX_IOPAD(0x8dc, PIN_OUTPUT | MUX_MODE0) /* P9.32, lcd_data15 */
            AM33XX_IOPAD(0x820, PIN_OUTPUT | MUX_MODE1) /* P9.19, lcd_data23 */
            AM33XX_IOPAD(0x824, PIN_OUTPUT | MUX_MODE1) /* P9.13, lcd_data22 */
            AM33XX_IOPAD(0x828, PIN_OUTPUT | MUX_MODE1) /* P9.14, lcd_data21 */
            AM33XX_IOPAD(0x82c, PIN_OUTPUT | MUX_MODE1) /* P9.17, lcd_data20 */
            AM33XX_IOPAD(0x830, PIN_OUTPUT | MUX_MODE1) /* P9.12, lcd_data19 */
            AM33XX_IOPAD(0x834, PIN_OUTPUT | MUX_MODE1) /* P9.11, lcd_data18 */
            AM33XX_IOPAD(0x838, PIN_OUTPUT | MUX_MODE1) /* P9.16, lcd_data17 */
            AM33XX_IOPAD(0x83c, PIN_OUTPUT | MUX_MODE1) /* P9.15, lcd_data16 */
            AM33XX_IOPAD(0x8e0, PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* P9.27, lcd_vsync */
            AM33XX_IOPAD(0x8e4, PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* P9.29, lcd_hsync */
            AM33XX_IOPAD(0x8e8, PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* P9.28, lcd_pclk */
            AM33XX_IOPAD(0x8ec, PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* P9.30, lcd_ac_bias_en */
            /* LCD enable */
            AM33XX_IOPAD(0x88c, PIN_OUTPUT_PULLUP | MUX_MODE7) /* P8.19, gpio2[1] */
        >;
    };

    backlight_pin: backlight_pin {
        pinctrl-single,pins = < AM33XX_IOPAD(0x848, PIN_OUTPUT | MUX_MODE6) >; /* P9.14, gpio1[18] */
    };

    touchscreen_pins: touchscreen_pins {
        pinctrl-single,pins = < AM33XX_IOPAD(0x9a4, PIN_INPUT_PULLUP | MUX_MODE7) >; /* P9.27, gpio3[19] */
    };

    dcan0_pins: dcan0_pins {
        pinctrl-single,pins = <
            AM33XX_IOPAD(0x97c, PIN_INPUT_PULLUP | MUX_MODE2) /* P9.19, ddcan0_rx */
            AM33XX_IOPAD(0x978, PIN_OUTPUT_PULLUP | MUX_MODE2) /* P9.20, ddcan0_tx */
        >;
    };

    uart1_pins: uart1_pins {
        pinctrl-single,pins = <
            AM33XX_IOPAD(0x980, PIN_INPUT_PULLUP | MUX_MODE0) /* P9.26, uart1_rxd */
            AM33XX_IOPAD(0x984, PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* P9.24, uart1_txd */
        >;
    };

    uart2_pins: uart2_pins {
        pinctrl-single,pins = <
            AM33XX_IOPAD(0x950, PIN_INPUT_PULLUP | MUX_MODE1) /* P9.22, uart2_rxd */
            AM33XX_IOPAD(0x954, PIN_OUTPUT_PULLDOWN | MUX_MODE1) /* P9.21, uart2_txd */
        >;
    };

    uart4_pins: uart4_pins {
        pinctrl-single,pins = <
            AM33XX_IOPAD(0x870, PIN_INPUT_PULLUP | MUX_MODE6) /* P9.11, uart4_rxd */
            AM33XX_IOPAD(0x874, PIN_OUTPUT_PULLDOWN | MUX_MODE6) /* P9.13, uart4_txd */
        >;
    };

    uart5_pins: uart5_pins {
        pinctrl-single,pins = <
            AM33XX_IOPAD(0x8c4, PIN_INPUT_PULLUP | MUX_MODE4) /* P8.38, uart5_rxd */
            AM33XX_IOPAD(0x8c0, PIN_OUTPUT_PULLDOWN | MUX_MODE4) /* P8.37, uart5_txd */
        >;
    };

    ehrpwm1_pins: ehrpwm1_pins {
        pinctrl-single,pins = <
            AM33XX_IOPAD(0x848, PIN_OUTPUT | MUX_MODE6) /* P9.14, EHRPWM1A */
            AM33XX_IOPAD(0x84c, PIN_OUTPUT | MUX_MODE6) /* P9.16, EHRPWM1B */
        >;
    };
};

&epwmss1 {
    status = "okay";
};

&ehrpwm1 {
    pinctrl-name = "default";
    pinctrl-0 = <&backlight_pin>;
    status = "okay";
};

&lcdc {
    status = "okay";
    blue-and-red-wiring = "crossed";
};

&sgx {
    status = "okay";
};

/ {
    lcd0: display {
        status = "okay";
        compatible = "ti,tilcdc,panel";
        label = "lcd";
        pinctrl-names = "default";
        pinctrl-0 = <&lcd_pins>;
        enable-gpios = <&gpio2 1 GPIO_ACTIVE_HIGH>; /* P8.19 */

        panel-info {
            ac-bias = <255>;
            ac-bias-intrpt = <0>;
            dma-burst-sz = <16>;
            bpp = <32>;
            fdd = <0x80>;
            sync-edge = <0>;
            sync-ctrl = <0>;
            raster-order = <0>;
            fifo-th = <0>;
        };

        display-timings {
            native-mode = <&timing0>;
            timing0: 800x480 {
                clock-frequency = <45000000>;
                hactive = <800>;
                vactive = <480>;
                hfront-porch = <40>;
                hback-porch = <40>;
                hsync-len = <48>;
                vback-porch = <29>;
                vfront-porch = <13>;
                vsync-len = <3>;
                hsync-active = <0>;
                vsync-active = <0>;
            };
        };
    };
};

&i2c2 {
    polytouch: edt-ft5x06@38 {
        compatible = "edt,edt-ft5406", "edt,edt-ft5x06";
        reg = <0x38>;
        pinctrl-names = "default";
        pinctrl-0 = <&touchscreen_pins>;
        interrupt-parent = <&gpio3>;
        interrupts = <19 0>; /* P9.27 */
        touchscreen-size-x = <799>;
        touchscreen-size-y = <479>;
        xfuzz = <0>;
        yfuzz = <0>;
    };
};

&rtc {
    system-power-controller;
};

&dcan0 {
    status = "okay";
    pinctrl-name = "default";
    pinctrl-0 = <&dcan0_pins>;
};

&uart1 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&uart1_pins>;
};

&uart2 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&uart2_pins>;
};

&uart4 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&uart4_pins>;
};

答案1

问题出在这一部分

&ehrpwm1 {
    pinctrl-name = "default";
    pinctrl-0 = <&backlight_pin>;
    status = "okay";
};

pinctrl-name应该是pinctrl-names(注意末尾的“s”)

相关内容