3.2.4.11. PWM¶
Introduction
PWMSS software architecture
Driver Configuration
Procedure to build eHRPWM driver
Device Drivers --->
<*> Pulse Width Modulation(PWM) Support --->
<*> eHRPWM PWM support
Procedure to build eCAP driver
Device Drivers --->
<*> Pulse Width Modulation(PWM) Support --->
<*> eCAP PWM support
Driver Usage
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/pwmchipN
Where,
‘N’ is the eCAP instance.
- Request and Control attributes
- Configuration attributes
Note
- Below examples uses eCAP instance 0 (i = 0).
Type 1 attributes
- *export* Attribute.
Ask the kernel to export a PWM channel. Writing 0 to the export attribute Acquires the channel and writing 0 to the unexport attribute Frees/Releases the channel. Before performing any operations, device has to be requested first.
- Request the Device:
target$ echo 0 > /sys/class/pwm/pwmchip0/export
- free the device:
target$ echo 0 > /sys/class/pwm/pwmchip0/unexport
- *run* Attribute
Enable/disable the PWM channel
- Enable the PWM
target$ echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable
- Disable the PWM
target$ echo 0 > /sys/class/pwm/pwmchip0/pwm0/enable
Type 2 attributes
- *period* Attribute
Enter the period in nano seconds value.
target$ echo 1000000000 > /sys /class/pwm/pwmchip0/pwm0/period
- *duty_cycle* Attribute
Enter the Duty cycle value in nanoseconds.
target$ echo val > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
- *Polarity* Attribute.
Setup Signal Polarity
target$ echo 1 > /sys /class/pwm/pwmchip0/pwm0/polarity
target$ echo 0 > /sys /class/pwm/pwmchip0/pwm0/polarity
Controlling backlight
target$ echo val > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
target$ echo val > /sys/class/backlight/backlight.8/brightness
‘val’ can range from 0 to 8.