Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
en:c1_hardware_pwm [2015/02/22 12:58] odroid [duty0] |
en:c1_hardware_pwm [2015/02/22 12:59] odroid [duty0] |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Hardware PWM ====== | ||
+ | ---- | ||
+ | **ODROID-C1** Has two possible PWM ports. One port is shared with SPI. | ||
+ | |||
+ | Starting from [[C1_Ubuntu_release_note_v1.1|Ubuntu Release (v1.1)]] or a kernel update performed on 2015-01-01 or later includes the PWM support. | ||
+ | |||
+ | |||
+ | ===== Usage ===== | ||
+ | For pin position, numbers and names, please refer to the pinmap [[http://odroid.com/dokuwiki/doku.php?id=en:c1_hardware#expansion_connectors|Expansion Connector]] | ||
+ | === Option 1: Single PWM and SPI === | ||
+ | The code below loads the PWM module with a single PWM and the PWM controller module. | ||
+ | |||
+ | //**PWN PIN: 33**// | ||
+ | |||
+ | <code> | ||
+ | sudo modprobe pwm-meson npwm=1 | ||
+ | sudo modprobe pwm-ctrl | ||
+ | </code> | ||
+ | |||
+ | |||
+ | === Option 2: Two PWM and **NO-SPI** === | ||
+ | //**PWM PINS:**// | ||
+ | |||
+ | //**PWM0: 33**// | ||
+ | |||
+ | //**PWM1: 19**// | ||
+ | |||
+ | <code> | ||
+ | sudo modprobe pwm-meson npwm=2 | ||
+ | sudo modprobe pwm-ctrl | ||
+ | </code> | ||
+ | |||
+ | |||
+ | ==== Examples of usage ==== | ||
+ | You can control this pwm via simple sysfs entries. | ||
+ | |||
+ | On **/sys/devices/platform/pwm-ctrl** You'll find the following files: | ||
+ | |||
+ | ==== duty0 ==== | ||
+ | Duty cycle of 1023 (10bit resolution) <code>echo 102 > duty0</code> will result in 102/1023 (approx 10%) of Duty cycle.\\ \\ | ||
+ | <code>echo 512 > duty0</code> will result 50:50 of Duty cycle. | ||
+ | |||
+ | ==== enable0 ==== | ||
+ | Enable/Disable this PWM <code>echo 1 > enable0</code> Will enable this PWM <code>echo 0 > enable0</code> Will disable this PWM. | ||
+ | |||
+ | ==== freq0 ==== | ||
+ | This is the PWM Frequency in Hertz! <code>echo 100000 > freq0</code> This will set the frequency to 100kHz | ||
+ | |||
+ | **Maximum Frequency is 1Mhz.** | ||
+ | |||
+ | On PWM0 you can test higher frequencies. There are not guarantee's! | ||
+ | 1Mhz is what we support. | ||
+ | |||
+ | |||
+ | <WRAP left round important 100%> | ||
+ | If you are using TWO pwm setup, You have: | ||
+ | enable0, freq0, duty0 __AND__ | ||
+ | enable1, freq1, duty1 | ||
+ | </WRAP> |