Firefly开源社区

【求助】新人PWM问题提问~~~

40

积分

0

威望

0

贡献

游客

积分
40
发表于 2016-8-22 13:09:17     
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/pwm.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/of_platform.h>
#define GPIO_LOW 0
#define GPIO_HIGH 1
struct pwm_device *pwm1         = NULL;
/*static int __init led_init(void)
{
        int i;
        for(i=0;i<=1000;i++)
        {
        //gpio_set_value(LED_GPIO,GPIO_LOW);
        printk("---------------kkkkkkkkkkkkkk----------------------------------------------\n");       
        //mdelay(500);
        //gpio_set_value(LED_GPIO,GPIO_HIGH);
        mdelay(500);
        }
        return 0;
}*/
static int firefly_hello_probe(struct platform_device *pdev)
{
        /*int ret = -1;
                int i;
        int gpio,flag;
                struct device_node *hello_node = pdev->dev.of_node;
                gpio = of_get_named_gpio_flags(hello_node,"led", 0,&flag);
                if (!gpio_is_valid(gpio)){
                return -1;
                }               
        ret = gpio_request(gpio,"hello_led");
                if (ret != 0){
                        gpio_free(gpio);
                        return -EIO;
                }
       
        gpio_direction_output(gpio,GPIO_HIGH);
        for(i=0;i<=20;i++)
        {
        gpio_set_value(gpio,GPIO_LOW);
        mdelay(500);
        gpio_set_value(gpio,GPIO_HIGH);
        mdelay(500);
        }*/
       
       
        pwm1 = pwm_request(1,"backlight-pwm");
        pwm_enable(pwm1);
        pwm_config(pwm1,500000, 1000000);
        mdelay(1000000);
        return 0;

}
static int firefly_hello_remove(struct platform_device *pdev)
{
        return 0;
}

static const struct of_device_id rk_pwm_of_match[]={
        {.compatible = "rockchip,rk-pwm"},
        {                                  }
};

static struct platform_driver firefly_hello_driver = {
        .probe                = firefly_hello_probe,
        .remove                = firefly_hello_remove,
        .driver                = {
                .name        = "backlight-pwm",
                .owner        = THIS_MODULE,
                .of_match_table = rk_pwm_of_match,
                        } ,
};       

static int __init hello_init(void)
{
        return platform_driver_register(&firefly_hello_driver);
        return 0;
}

static void __exit hello_exit(void)
{
        platform_driver_unregister(&firefly_hello_driver);
}


subsys_initcall(hello_init);
module_exit(hello_exit);

MODULE_AUTHOR("KK");
MODULE_DESCRIPTION("KK");       
MODULE_LICENSE("GPL");

这是我的.C文件

pwm1: pwm@ff680010 {
        compatible = "rockchip,rk-pwm";
        reg = <0xff680010 0x10>;
        #pwm-cells = <2>;
        pinctrl-names = "default";
        pinctrl-0 = <&pwm1_pin>;
        clocks = <&clk_gates11 11>;
        clock-names = "pclk_pwm";
        status = "okay";
    };

DTS配置按维基来的

现在情况是编译能通过 内核下进板子后我理解就是开机的时候用万用表打到DC档测试PWM1 接口应该有变化但是现在变化很微弱 求助啊。。。
回复

使用道具 举报

143

积分

0

威望

0

贡献

技术小白

积分
143
发表于 2016-8-22 14:31:29     
楼主你是怎么测到电流变化的??我用了你这个程序,make然后insmod,把pwm1口接到示波器上,没有发现方波,请问是怎么回事
回复

使用道具 举报

40

积分

0

威望

0

贡献

游客

积分
40
发表于 2016-8-22 14:46:26     
zzj 发表于 2016-8-22 14:31
楼主你是怎么测到电流变化的??我用了你这个程序,make然后insmod,把pwm1口接到示波器上,没有发现方波, ...

没测电流 测的是电压吧  你那有PWM的例子没 我才用这个我也不知道写的对不  反正基本没反应但是编译啥都没问题- -
回复

使用道具 举报

143

积分

0

威望

0

贡献

技术小白

积分
143
发表于 2016-8-22 15:20:59     
cctvzk 发表于 2016-8-22 14:46
没测电流 测的是电压吧  你那有PWM的例子没 我才用这个我也不知道写的对不  反正基本没反应但是编译啥都 ...

我也是用示波器测的电压,我用的例子也是wiki里面那个,我接了个LED,然后申请配置使能,但led的亮度一点变化没有,已经弄了几天了就是没搞懂,只能用延时在普通io口输出模拟pwm
回复

使用道具 举报

40

积分

0

威望

0

贡献

游客

积分
40
发表于 2016-8-22 15:26:42     
zzj 发表于 2016-8-22 15:20
我也是用示波器测的电压,我用的例子也是wiki里面那个,我接了个LED,然后申请配置使能,但led的亮度一点 ...

好吧。。。我也发现了 这论坛基本没能用的PWM例子- -  你那个能发来参考参考么 - -
回复

使用道具 举报

143

积分

0

威望

0

贡献

技术小白

积分
143
发表于 2016-8-22 16:03:28     
cctvzk 发表于 2016-8-22 15:26
好吧。。。我也发现了 这论坛基本没能用的PWM例子- -  你那个能发来参考参考么 - -

http://developer.t-firefly.com/thread-10758-1-1.html,就是这个帖子,你也帮我看看{:3_58:}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表