summaryrefslogtreecommitdiffstatshomepage
path: root/docs/library/pyb.Timer.rst
diff options
context:
space:
mode:
authorDave Hylands <dhylands@gmail.com>2015-03-09 01:04:12 -0700
committerDamien George <damien.p.george@gmail.com>2015-03-09 13:23:14 +0000
commitb4c9a25eabcf67cdb4317a22cf2b3eeba9c4d7aa (patch)
tree00d4508f79ff7bc5f9d4ce5eeb81d00654eae37a /docs/library/pyb.Timer.rst
parentb57b56f2932aa7f35c32e6d57e79ba8947407363 (diff)
downloadmicropython-b4c9a25eabcf67cdb4317a22cf2b3eeba9c4d7aa.tar.gz
micropython-b4c9a25eabcf67cdb4317a22cf2b3eeba9c4d7aa.zip
stmhal: Add support for quadrature encoder mode to pyb.TimerChannel.
Diffstat (limited to 'docs/library/pyb.Timer.rst')
-rw-r--r--docs/library/pyb.Timer.rst17
1 files changed, 15 insertions, 2 deletions
diff --git a/docs/library/pyb.Timer.rst b/docs/library/pyb.Timer.rst
index 78db71e542..b2f10320cf 100644
--- a/docs/library/pyb.Timer.rst
+++ b/docs/library/pyb.Timer.rst
@@ -76,14 +76,17 @@ Methods
- ``Timer.OC_FORCED_ACTIVE`` --- the pin is forced active (compare match is ignored).
- ``Timer.OC_FORCED_INACTIVE`` --- the pin is forced inactive (compare match is ignored).
- ``Timer.IC`` --- configure the timer in Input Capture mode.
-
+ - ``Timer.ENC_A`` --- configure the timer in Encoder mode. The counter only changes when CH1 changes.
+ - ``Timer.ENC_B`` --- configure the timer in Encoder mode. The counter only changes when CH2 changes.
+ - ``Timer.ENC_AB`` --- configure the timer in Encoder mode. The counter changes when CH1 or CH2 changes.
+
- ``callback`` - as per TimerChannel.callback()
- ``pin`` None (the default) or a Pin object. If specified (and not None)
this will cause the alternate function of the the indicated pin
to be configured for this timer channel. An error will be raised if
the pin doesn't support any alternate functions for this timer channel.
-
+
Keyword arguments for Timer.PWM modes:
- ``pulse_width`` - determines the initial pulse width value to use.
@@ -94,12 +97,14 @@ Methods
- ``compare`` - determines the initial value of the compare register.
- ``polarity`` can be one of:
+
- ``Timer.HIGH`` - output is active high
- ``Timer.LOW`` - output is acive low
Optional keyword arguments for Timer.IC modes:
- ``polarity`` can be one of:
+
- ``Timer.RISING`` - captures on rising edge.
- ``Timer.FALLING`` - captures on falling edge.
- ``Timer.BOTH`` - captures on both edges.
@@ -107,6 +112,14 @@ Methods
Note that capture only works on the primary channel, and not on the
complimentary channels.
+ Notes for Timer.ENC modes:
+
+ - Requires 2 pins, so one or both pins will need to be configured to use
+ the appropriate timer AF using the Pin API.
+ - Read the encoder value using the timer.counter() method.
+ - Only works on CH1 and CH2 (and not on CH1N or CH2N)
+ - The channel number is ignored when setting the encoder mode.
+
PWM Example::
timer = pyb.Timer(2, freq=1000)