Difference between revisions of "PWM"

From ArmadeusWiki
Jump to: navigation, search
m
m (Usage)
Line 19: Line 19:
  
 
== Usage ==
 
== Usage ==
Load the module:
+
* Load the module:
 
  # insmod /lib/modules/2.6.18.1/extra/pwm/pwm.ko
 
  # insmod /lib/modules/2.6.18.1/extra/pwm/pwm.ko
 
or (if you have reflashed your rootfs):
 
or (if you have reflashed your rootfs):
 
  # modprobe pwm
 
  # modprobe pwm
 +
* Create device file if not existing (Major is dynamically allocated)
 +
# DEV=`cat /proc/devices | grep imx-pwm | cut -d " " -f 1`; mknod /dev/pwm c $DEV 0
  
 
== PWM Mode ==
 
== PWM Mode ==

Revision as of 21:44, 30 November 2007

On this page, you will find usefull informations to configure and use the Pulse Width Modulation (PWM) capabilities of your APF9328 board.

Your board is capable of driving 2 PWM signals:

  • one is linked to the LCD controller and allow to control the LCD backlight
  • the other can be used to generate a PWM signal in several mode:
    • audio playback
    • real PWM

Configuration

First be sure to have the PWM Linux driver activated:

$ make linux-menuconfig

And in Device Drivers ---> Armadeus specific drivers choose:
Linux config pwm.png
Then rebuild your system:

$ make

Installation

Either copy generated module target/linux/modules/pwm/pwm.ko to your system with TFTP or NFS or reflash the generated rootfs

Usage

  • Load the module:
# insmod /lib/modules/2.6.18.1/extra/pwm/pwm.ko

or (if you have reflashed your rootfs):

# modprobe pwm
  • Create device file if not existing (Major is dynamically allocated)
# DEV=`cat /proc/devices | grep imx-pwm | cut -d " " -f 1`; mknod /dev/pwm c $DEV 0

PWM Mode

Remark:

  • The pwm has a resolution of 1uS


Now you have access to /sys/class/pwm/ functionnalities:

  • to activate PWM:
# echo 1 > /sys/class/pwm/pwm0/active
  • to de-activate PWM:
# echo 0 > /sys/class/pwm/pwm0/active
  • to change frequency (for example 500 Hz):
# echo 500 > /sys/class/pwm/pwm0/frequency
  • to change period (for example 100us):
# echo 100 > /sys/class/pwm/pwm0/period
  • to change duty cycle (for example 50.0%)
# echo 500 > /sys/class/pwm/pwm0/duty

Audio Mode

Audio playback mode is working since v0.5 of PWM driver (thanks to SebastienR). You can play 8, 16 & 32 KHz 8bit linear RAW sound. It's recommended to play 8kHz one, as they use less CPU ressources. To convert a sound to the right format we recommend to use SoX (on Linux). For exemple:

[host]$ sox /usr/share/sounds/KDE_Chimes_1.ogg -r 8192 -b -u -c 1 Chimes.raw
-r -> sampling rate
-b -> byte/8bit signal
-u -> linear /not compressed
-c 1 -> Mono / 1 channel

Then you can test it using target/linux/modules/pwm/test/testplaymode:

[host:/.../armadeus]$ make -C target/linux/modules/pwm/test/
[host:/.../armadeus]$ cp target/linux/modules/pwm/test/testplaymode $NFS_DIR
[host:/.../armadeus]$ cp target/linux/modules/pwm/test/KDE_Startup_2.raw $NFS_DIR

on target do:

# testplaymode

or

# testplaymode KDE_Startup_2.raw

Links