diff options
| author | Jon Rob <mr.jonrob@gmail.com> | 2020-06-08 06:29:43 +0000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2020-06-17 00:03:33 +1000 |
| commit | 1678f417445703750e187b1b8a83c8c3e0e3796f (patch) | |
| tree | 155df1e2d308ce0582fdf4ecba647ed98e7b0a30 /docs/library/esp32.rst | |
| parent | a51eef4471e01ee60d53ee184bc4feabf6ebd855 (diff) | |
esp32/esp32_rmt: Extend RMT to support carrier feature.
The ESP32 RMT peripheral has hardware support for a carrier frequency, and
this commit exposes it to Python with the keyword arguments carrier_freq
and carrier_duty_percent in the constructor. Example usage:
r = esp32.RMT(0, pin=Pin(2), clock_div=80, carrier_freq=38000, carrier_duty_percent=50)
Diffstat (limited to 'docs/library/esp32.rst')
| -rw-r--r-- | docs/library/esp32.rst | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/docs/library/esp32.rst b/docs/library/esp32.rst index 33b779a21..715afddde 100644 --- a/docs/library/esp32.rst +++ b/docs/library/esp32.rst @@ -151,6 +151,11 @@ used to transmit or receive many other types of digital signals:: r = esp32.RMT(0, pin=Pin(18), clock_div=8) r # RMT(channel=0, pin=18, source_freq=80000000, clock_div=8) + + # To use carrier frequency + r = esp32.RMT(0, pin=Pin(18), clock_div=8, carrier_freq=38000) + r # RMT(channel=0, pin=18, source_freq=80000000, clock_div=8, carrier_freq=38000, carrier_duty_percent=50) + # The channel resolution is 100ns (1/(source_freq/clock_div)). r.write_pulses((1, 20, 2, 40), start=0) # Send 0 for 100ns, 1 for 2000ns, 0 for 200ns, 1 for 4000ns @@ -164,6 +169,9 @@ define the pulses. multiplying the resolution by a 15-bit (0-32,768) number. There are eight channels (0-7) and each can have a different clock divider. +To enable the carrier frequency feature of the esp32 hardware, specify the +``carrier_freq`` as something like 38000, a typical IR carrier frequency. + So, in the example above, the 80MHz clock is divided by 8. Thus the resolution is (1/(80Mhz/8)) 100ns. Since the ``start`` level is 0 and toggles with each number, the bitstream is ``0101`` with durations of [100ns, 2000ns, @@ -174,17 +182,20 @@ For more details see Espressif's `ESP-IDF RMT documentation. .. Warning:: The current MicroPython RMT implementation lacks some features, most notably - receiving pulses and carrier transmit. RMT should be considered a + receiving pulses. RMT should be considered a *beta feature* and the interface may change in the future. -.. class:: RMT(channel, \*, pin=None, clock_div=8) +.. class:: RMT(channel, \*, pin=None, clock_div=8, carrier_freq=0, carrier_duty_percent=50) This class provides access to one of the eight RMT channels. *channel* is required and identifies which RMT channel (0-7) will be configured. *pin*, also required, configures which Pin is bound to the RMT channel. *clock_div* is an 8-bit clock divider that divides the source clock (80MHz) to the RMT - channel allowing the resolution to be specified. + channel allowing the resolution to be specified. *carrier_freq* is used to + enable the carrier feature and specify its frequency, default value is ``0`` + (not enabled). To enable, specify a positive integer. *carrier_duty_percent* + defaults to 50. .. method:: RMT.source_freq() |
