我有一个运行Debian Jessie的BBB。我有一个改进的LCD4斗篷,运行良好。我的LCD斗篷使用EHRPWM1A。我想使用EHRPWM1B的PWM输出。它会附着在一个压电蜂鸣器上。
我知道当我的LCD cape未启用时,我可以使用PWM输出。我修改了BB-BONE-BACONE斗篷以创建2个PWM输出。我知道可以同时控制LCD的背光和蜂鸣器的PWM。
启用我的LCD开关后,我可以为我的蜂鸣器输出PWM通道,设置我的周期和占空比,但是我没有输出。有人对这是为什么有任何想法吗?
我的猜测是我不明白/ sys / class /背光如何与PWM交互,但我不确定。
答案 0 :(得分:1)
所以我设法通过将PWM编译到叠加层来实现这一点。
对于将来对此感兴趣的任何人,我已经发布了我在下面使用的叠加层。
/*
* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
/dts-v1/;
/plugin/;
#include <dt-bindings/board/am335x-bbw-bbb-base.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/am33xx.h>
/ {
compatible = "ti,beaglebone", "ti,beaglebone-black", "ti,beaglebone-green";
/* identification */
part-number = "BB-BONE-LCD4-01";
version = "00A2";
/* state the resources this cape uses */
exclusive-use =
/* the pin header uses */
"P8.45", /* lcd: lcd_data0 */
"P8.46", /* lcd: lcd_data1 */
"P8.43", /* lcd: lcd_data2 */
"P8.44", /* lcd: lcd_data3 */
"P8.41", /* lcd: lcd_data4 */
"P8.42", /* lcd: lcd_data5 */
"P8.39", /* lcd: lcd_data6 */
"P8.40", /* lcd: lcd_data7 */
"P8.37", /* lcd: lcd_data8 */
"P8.38", /* lcd: lcd_data9 */
"P8.36", /* lcd: lcd_data10 */
"P8.34", /* lcd: lcd_data11 */
"P8.35", /* lcd: lcd_data12 */
"P8.33", /* lcd: lcd_data13 */
"P8.31", /* lcd: lcd_data14 */
"P8.32", /* lcd: lcd_data15 */
"P8.27", /* lcd: lcd_vsync */
"P8.29", /* lcd: lcd_hsync */
"P8.28", /* lcd: lcd_pclk */
"P8.30", /* lcd: lcd_ac_bias_en */
"P9.16", /* buzzer pin */
"ehrpwm1a",
"ehrpwm1b",
"lcdc",
"tscadc";
fragment@0 {
target = <&am33xx_pinmux>;
__overlay__ {
bb_lcd_pwm_backlight_pins: pinmux_bb_lcd_pwm_backlight_pins {
pinctrl-single,pins = <
BONE_P9_14 (PIN_OUTPUT_PULLDOWN | MUX_MODE6) /* gpmc_a2.ehrpwm1a */
BONE_P9_16 (PIN_OUTPUT_PULLDOWN | MUX_MODE6) /* gpmc_a2.ehrpwm1a */
>;
};
bb_lcd_lcd_pins: pinmux_bb_lcd_lcd_pins {
pinctrl-single,pins = <
BONE_P9_27 (PIN_OUTPUT_PULLUP | MUX_MODE7) /* mcasp0_fsr.gpio3_19 */
BONE_P8_45 (PIN_OUTPUT | MUX_MODE0) /* lcd_data0.lcd_data0 */
BONE_P8_46 (PIN_OUTPUT | MUX_MODE0) /* lcd_data1.lcd_data1 */
BONE_P8_43 (PIN_OUTPUT | MUX_MODE0) /* lcd_data2.lcd_data2 */
BONE_P8_44 (PIN_OUTPUT | MUX_MODE0) /* lcd_data3.lcd_data3 */
BONE_P8_41 (PIN_OUTPUT | MUX_MODE0) /* lcd_data4.lcd_data4 */
BONE_P8_42 (PIN_OUTPUT | MUX_MODE0) /* lcd_data5.lcd_data5 */
BONE_P8_39 (PIN_OUTPUT | MUX_MODE0) /* lcd_data6.lcd_data6 */
BONE_P8_40 (PIN_OUTPUT | MUX_MODE0) /* lcd_data7.lcd_data7 */
BONE_P8_37 (PIN_OUTPUT | MUX_MODE0) /* lcd_data8.lcd_data8 */
BONE_P8_38 (PIN_OUTPUT | MUX_MODE0) /* lcd_data9.lcd_data9 */
BONE_P8_36 (PIN_OUTPUT | MUX_MODE0) /* lcd_data10.lcd_data10 */
BONE_P8_34 (PIN_OUTPUT | MUX_MODE0) /* lcd_data11.lcd_data11 */
BONE_P8_35 (PIN_OUTPUT | MUX_MODE0) /* lcd_data12.lcd_data12 */
BONE_P8_33 (PIN_OUTPUT | MUX_MODE0) /* lcd_data13.lcd_data13 */
BONE_P8_31 (PIN_OUTPUT | MUX_MODE0) /* lcd_data14.lcd_data14 */
BONE_P8_32 (PIN_OUTPUT | MUX_MODE0) /* lcd_data15.lcd_data15 */
BONE_P8_27 (PIN_OUTPUT | MUX_MODE0) /* lcd_vsync.lcd_vsync */
BONE_P8_29 (PIN_OUTPUT | MUX_MODE0) /* lcd_hsync.lcd_hsync */
BONE_P8_28 (PIN_OUTPUT | MUX_MODE0) /* lcd_pclk.lcd_pclk */
BONE_P8_30 (PIN_OUTPUT | MUX_MODE0) /* lcd_ac_bias_en.lcd_ac_bias_en */
>;
};
};
};
fragment@1 {
target = <&epwmss1>;
__overlay__ {
status = "okay";
};
};
fragment@2 {
target = <&ehrpwm1>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&bb_lcd_pwm_backlight_pins>;
status = "okay";
};
};
fragment@3 {
target = <&lcdc>;
__overlay__ {
status = "okay";
};
};
fragment@4 {
target = <&tscadc>;
__overlay__ {
status = "okay";
tsc {
ti,wires = <4>;
ti,x-plate-resistance = <200>;
ti,coordinate-readouts = <5>;
ti,wire-config = <0x00 0x11 0x22 0x33>;
};
adc {
ti,adc-channels = <4 5 6 7>;
};
};
};
fragment@5 {
target-path="/";
__overlay__ {
/* avoid stupid warning */
#address-cells = <1>;
#size-cells = <1>;
backlight {
status = "okay";
compatible = "pwm-backlight";
pwms = <&ehrpwm1 0 250000 0>;
brightness-levels = <
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47 48 49
50 51 52 53 54 55 56 57 58 59
60 61 62 63 64 65 66 67 68 69
70 71 72 73 74 75 76 77 78 79
80 81 82 83 84 85 86 87 88 89
90 91 92 93 94 95 96 97 98 99
100
>;
default-brightness-level = <100>;
};
panel {
status = "okay";
compatible = "ti,tilcdc,panel";
pinctrl-names = "default";
pinctrl-0 = <&bb_lcd_lcd_pins>;
panel-info {
ac-bias = <255>;
ac-bias-intrpt = <0>;
dma-burst-sz = <16>;
bpp = <16>;
fdd = <0x80>;
sync-edge = <0>;
sync-ctrl = <1>;
raster-order = <0>;
fifo-th = <0>;
};
display-timings {
native-mode = <&timing0>;
/* www.newhavendisplay.com/app_notes/OTA5180A.pdf */
timing0: 480x272 {
clock-frequency = <9200000>;
hactive = <480>;
vactive = <272>;
hfront-porch = <8>;
hback-porch = <47>;
hsync-len = <41>;
vback-porch = <2>;
vfront-porch = <3>;
vsync-len = <10>;
hsync-active = <0>;
vsync-active = <0>;
de-active = <1>;
pixelclk-active = <0>;
};
};
};
};
};
};
对于PWM控制,请使用以下命令:
sudo su //or log in as root
echo 1 > /sys/class/pwm/pwmchip0/export //export PWM to userspace
cd /sys/class/pwm/pwmchip0/pwm1 //change directories to make things a bit easier
echo 250000 > period //NOTE: this number must match the frequency used for the LCD backlight
echo 125000 > duty_cycle //set our duty cycle of the PWM in nano seconds
echo 1 > enable //turn PWM on
echo 0 > enable //turn PWM off
希望这有助于其他人。