脉宽调制子系统(Pluse-Width Modulation SubSystem--PWMSS)由增强高分辨率脉宽调制器(eHRPWM),强采集(eCAP),强正交编码脉冲(eQEP)三个模块构成。

eHRPWM

eHRPWM是一个比较实用的外围设备,它可以在最小的CPU开销下产生复杂的脉宽波形。一个完整的ePWM模块由两路PWM输出组成,EPWMA和EPWMB。

1, 专用的16位time-base用作周期或是频率控制

2, 两路PWM输出能按下面的方式配置:

1, 两个独立的PWM输出用作单沿操作

2, 两个独立的PWM输出用作双沿对称操作

3, 一个独立的PWM输出用作双沿对称操作

3, 可编程的中断事件,并且是最小的CPU开销

eCAP

eCAP模块既可以用作PWM功能,也可用作采集功能。

1, 专用的外部PIN脚

2, 32位Time Base计数器

3, 4*32位时间戳采集寄存器(CAP1-CAP4)

4, 预缩放的输入采集信号

5, 中断功能可以由任意四个采集事件触发

当前PWM驱动只能支持下面特性:

1, eHRPWMg与eCAP可以支持

2, eCAP只能支持PWM模式

PWMSS软件架构如下图:

驱动的配置:

选择eHRPWM驱动

Device Drivers ---><*> PWM Support ---><*> Davinci eHRPWM support  

选择eCAP驱动

         Device Drivers ---><*> PWM Support ---><*> eCAP PWM support   
大家还要注意PIN脚模式的选择和配置,否则驱动控制不了PIN脚

eHRPWM

eHRPWM can be controlled from the user space through SYSFS interface. SYSFS interface for eHRPWM is available at

/sys/class/pwm/ehrpwm.i:j

Where,

‘i’ is the eHRPWM instance
‘j’ is the eHRPWM ouptut 0 or 1[Each instance of eHRPWM has 2 channel outputs]

Various SYSFS Attributes

2 types of SYSFS attributes are available

  1. Request and Control attributes
  2. Configuration attributes

Note

  • Below examples uses eHRPWM instance 2 and output channel 0 (i = 2, j = 0).

Type 1 attributes

  • request Attribute.

Request PWM-SS for permission to use the module. Writing 1 to the request attribute Acquires the device and writing 0 to the request attribute Frees/Releases the device. Before performing any operations, device has to be requested first.

Example

  • Request the Device:
target$ echo 1 > /sys/class/pwm/ehrpwm.2:0/request
  • free the device:
target$ echo 0 > /sys/class/pwm/ehrpwm.2:0/request
  • run Attribute

Start or Stop the PWM Module. 0 – Stop Module, 1 – Start module.

Example

  • Start the PWM
target$ echo 1 > /sys/class/pwm/ehrpwm.2:0/run
  • Stop the PWM
target$ echo 0 > /sys/class/pwm/ehrpwm.2:0/run

CAUTION
Before enabling the module, the module needs to be configured using below configuration attributes. Else proper operation is not assured.

Type 2 attributes

i.Setting the Period
Following attributes set the period of the PWM waveform.

  • frequency Attribute

Enter the period in HZ. Once the frequency is configured, make sure to set the duty cycle value.

Example
Setup PWM to generate a pwm signal of 100 HZ with 50% duty cycle.

target$ echo 100 > /sys/class/pwm/ehrpwm.2:0/period_freq
target$ echo 50 > /sys/class/pwm/ehrpwm.2:0/duty_percent
  • period_ns Attribute

Enter the period in nano seconds value.

Example
if the period is 1 sec , enter

target$ echo 1000000000 > /sys /class/pwm/ehrpwm.2:0/period_ns

ii.Setting the Duty
Following attributes set the duty of the PWM waveform.

  • duty_percent Attribute

Enter the Duty cycle value in percentage.

Example
To configure for 50% duty cycle, enter

target$ echo 50 > /sys/class/pwm/ehrpwm.2:0/duty_percent
  • duty_ns Attribute

duty_ns takes the duty cycle value in nano seconds.

Example
To configure for 0.5s, enter

target$ echo 500000000 > /sys /class/pwm/ehrpwm.2:0/duty_ns

iii.Setting the Polarity

  • Polarity Attribute.

Setup Signal Polarity

Example
To set the polarity to Active High, Enter

target$ echo 1 > /sys /class/pwm/ehrpwm.2:0/polarity

Example
To set the polarity to Active Low, Enter

target$ echo 0 > /sys /class/pwm/ehrpwm.2:0/polarity

Example Configuration:
Following example shows steps to configure the PWM for 100 HZ with 50% duty cycle.

target$ echo 1 >  /sys/class/pwm/ehrpwm.2:0/request
target$ echo 100 > /sys/class/pwm/ehrpwm.2:0/period_freq
target$ echo 50 > /sys/class/pwm/ehrpwm.2:0/duty_percent
target$ echo 1 > /sys/class/pwm/ehrpwm.2:0/run

Issuing above commands will generate PWM wave. This can be verified by probing to eHRPWM pin.

IMPORTANT

  1. To change the frequency, first stop the PWM waveform, reset the duty to zero and then follow the last 3 steps in the above Example Configuration.
  2. eHRPWM 2 instance channel 1 pwm pin is hooked to Haptics AM335x EVM. Changing the duty percentage/frequency will affect the speed of the Haptics.

Controlling haptics

Haptics on Evaluation Module can be controlled through eHRPWM sysfs interface.

IMPORTANT

In order to run Haptics using eHRPWM interface, the Evaluation Module needs to be in Profile 4.

target$ echo 1 > /sys/class/pwm/ehrpwm.2:1/request
target$ echo 250 > /sys/class/pwm/ehrpwm.2:1/period_freq
target$ echo 50 > /sys/class/pwm/ehrpwm.2:1/duty_percent
target$ echo 1 > /sys/class/pwm/ehrpwm.2:1/run

eCAP

The current release of the driver supports only PWM mode. eCAP can be controlled from the user space through SYSFS interface. SYSFS interface for eCAP is available at

target$ cat /sys/class/pwm/ecap.i

Where,

‘i’ is the eCAP instance.

Various SYSFS Attributes

2 types of SYSFS attributes are available

  1. Request and Control attributes
  2. Configuration attributes

Note

  • Below examples uses eCAP instance 0 (i = 0).

Type 1 attributes

  • request Attribute.

Request PWM-SS for permission to use the module. Writing 1 to the request attribute Acquires the device and writing 0 to the request attribute Frees/Releases the device. Before performing any operations, device has to be requested first.

Example

  • Request the Device:
target$ echo 1 > /sys/class/pwm/ecap.0/request
  • free the device:
target$ echo 0 > /sys/class/pwm/ecap.0/request
  • run Attribute

Start or Stop the PWM Module. 0 – Stop Module, 1 – Start module.

Example

  • Start the PWM
target$ echo 1 > /sys/class/pwm/ecap.0/run
  • Stop the PWM
target$ echo 0 > /sys/class/pwm/ecap.0/run

CAUTION
Before enabling the module, the module needs to be configured using below configuration attributes. Else proper operation is not assured.

Type 2 attributes

i.Setting the Period
Following attributes set the period of the PWM waveform.

  • frequency Attribute

Enter the period in HZ. Once the frequency is configured, make sure to set the duty cycle value.

Example
Setup PWM to generate a pwm signal of 100 HZ with 50% duty cycle.

target$ echo 100 > /sys/class/pwm/ecap.0/period_freq
target$ echo 50 > /sys/class/pwm/ecap.0/duty_percent
  • period_ns Attribute

Enter the period in nano seconds value.

Example
if the period is 1 sec , enter

target$ echo 1000000000 > /sys /class/pwm/ecap.0/period_ns

ii.Setting the Duty
Following attributes set the duty of the PWM waveform.

  • duty_percent Attribute

Enter the Duty cycle value in percentage.

Example
To configure for 50% duty cycle, enter

target$ echo 50 > /sys/class/pwm/ecap.0/duty_percent
  • duty_ns Attribute

duty_ns takes the duty cycle value in nano seconds.

Example
To configure for 0.5s, enter

target$ echo 500000000 > /sys /class/pwm/ecap.0/duty_ns

iii.Setting the Polarity

  • Polarity Attribute.

Setup Signal Polarity

Example
To set the polarity to Active High, Enter

target$ echo 1 > /sys /class/pwm/ecap.0/polarity

Example
To set the polarity to Active Low, Enter

target$ echo 0 > /sys /class/pwm/ecap.0/polarity

Example Configuration:
Following example shows steps to configure the PWM for 100 HZ with 50% duty cycle.

target$ echo 1 > /sys/class/pwm/ecap.0/request
target$ echo 100 > /sys/class/pwm/ecap.0/period_freq
target$ echo 50 > /sys/class/pwm/ecap.0/duty_percent
target$ echo 1 > /sys/class/pwm/ecap.0/run

Issuing above commands will generate PWM wave. This can be verified by probing to eCAP pin.

IMPORTANT

  1. To change the frequency, first stop the PWM waveform, reset the duty to zero and then follow the last 3 steps in the above Example Configuration.
  2. In this EVM, eCAP instance 0 pin is hooked to backlight of the LCD. Changing the duty percentage will affect the brightness of the LCD screen.

Controlling backlight

Following are the 2 procedures to vary brightness of the LCD screen.

i. Setting duty percentage of pwm wave from eCAP sysfs files

target$ echo val > /sys/class/pwm/ecap.0/duty_percent

'val' can range from 0 to 100.
ii. Setting brightness from backlight sysfs files

target$ echo val > /sys/class/backlight/pwm-backlight/brightness

AM335X PWMSS 驱动指导相关推荐

  1. Am335x lcd驱动分析

    2019独角兽企业重金招聘Python工程师标准>>> 一 文件列表 本文使用的为sdk6.0 kernel版本为3.2 并未使用dts am335x的lcd驱动相关文件有: (ke ...

  2. am335x USB 驱动框架记录

    参考: http://processors.wiki.ti.com/index.php/AM335x_USB_Driver%27s_Guide http://processors.wiki.ti.co ...

  3. AM335x LCD驱动解析

    文章目录 1. LCD背景 2. LCD驱动 2.1 Device 2.2 Driver 2.2.1 fbmem_init() 2.2.2 register_framebuffer() 2.2.3 / ...

  4. AM335X can驱动移植

    驱动选择 make menuconfig[*] Networking support ---><*> CAN bus subsystem support --->--- CAN ...

  5. c++驱动键鼠源码_Android移植FM芯片RDA5807M驱动指导

    文档说明 本文档以SC826为例(MSM8953平台,Android 7),描述如何移植FM芯片RDA5807M驱动. 移植修改 1):rdafm_drv.c rdafm_drv.h 放到kernel ...

  6. am335x gpio驱动

    任务:     GPIO0_19(带下拉)作为中断, GPIO0_20(带上拉)和GPIO1_14作为输出管脚,GPIO0_11(带下拉)和           GPIO1_15(带上拉).并编写驱动 ...

  7. zz-linux-i2c驱动分析am335x框架调用150103d

    //zz//####################################################################### zz-linux-i2c驱动分析am335x ...

  8. 计算机图文混合排版教学设计,图文表混合排版教学设计_百度文库(20页)-原创力文档...

    <图文表混合排版>教学设计 卢龙县职业技术教育中心 刘思晨 一.设计思想: 以学生自主探索.合作交流为主线,以培养学生的创新精神和学生自主合作探究学习方式为目标.在建构式的教与学活动中,让 ...

  9. 图漾DM430/FM810深度摄像头在ROS环境下的配置过程

    最近在学ROS,弄来两个图漾的深度摄像头,DM430(据说用的人挺多的)和FH810(升级版),两个的驱动应该是通用的 1.window下安装测试软件 在window10下装驱动运行测试程序,按照提供 ...

最新文章

  1. hadoop 基准测试与读写测试
  2. python整数二进制有多少个1_LintCode Python 入门级题目 365.二进制有多少个1; 181.将整数A转换为B...
  3. 内网端口 转发 穿透 工具简介
  4. Maven下载、配置环境变量、配置本地仓库、国内镜像源、在IDEA中配置Maven
  5. OpenGL无边界的纹理实例
  6. spring bean生命周期_Spring中bean的生命周期和扩展点有哪些?
  7. 微软实习期的我,纠正了一位高级开发人员的错误......
  8. exfat最佳单元大小_2020年Window系统重装最佳方式
  9. Eclipse快捷键收集
  10. php 函数内临时变量,在PHP中调用函数时使用临时变量
  11. /dev/null空字符设备文件
  12. 单片机设计经验设计技巧集锦
  13. 传递给Appium服务器以开启相应安卓Automation会话的Capabilities的几点说明
  14. ei会议和ei源刊的区别_EI论文发表EI期刊发表EI会议论文EI检索EI源刊
  15. java怎么修改支付宝步数_支付宝怎么修改运动步数 刷步数方法
  16. 滴滴快车奖励政策,高峰奖励,翻倍奖励,按成交率,指派单数分级(8月4日)...
  17. Could not acquire image ID or digest following build
  18. python-类的继承和多态-继承父类方法和属性的多种方法-继承多个类,继承顺序的研究
  19. 利用Python制作微信机器人(二)
  20. 计算机辅助教学课件中的辅导型模式是以,计算机辅助教学中个别指导型课件的设计.pdf...

热门文章

  1. 达内计算机软件测试,2015计算机软件测试工程师真题及答案
  2. java中的final关键字和effectively final
  3. Maven Profiles
  4. springboot+vue+java校园交友信息推荐网站
  5. 微信小程序开发问题集锦
  6. java 鼠标事件Dragged和Moved 及java显示GIF在JLabel、JButton
  7. 《华尔街:金钱永不眠》经典台词
  8. 智果内容付费系统php开源版本,智果内容付费系统商业版2.1.0版本更新啦~
  9. php对多个变量进行初始化,PHP如何对变量进行初始化和初始化
  10. 计算机管理器有感叹号,win7系统设备管理器键盘有黄色感叹号怎么办【图文】...