среда, 6 сентября 2017 г.

Exploring the ESP32’s Peripheral Blocks

For IoT or Home Control

What makes an embedded processor suitable as an IoT or home control device? Wi-Fi support is just part of the picture. Brian has done some Wi-Fi projects using the ESP32, so here he shares his insights about the peripherals on the ESP32 and why they’re so powerful.

By Brian Millier

If you’re interested in IoT or home control devices, you’ve undoubtedly run across Espressif’s ESP8266. The embedded processor became ubiquitous in a very short time. The successor to the ESP8266 is the ESP32 and it’s much more powerful. Like the ESP8266, the ESP32 has on chip Wi-Fi. But it also includes Bluetooth Low Energy (BLE) and sports two high-power cores in place of the single one found on the ESP8266.

Having two main cores means one can run the wireless protocol stack on one core, leaving the other core free for the user application program. In fact, Espressif labels the cores “App” and “Pro”, with the latter referring to the Wi-Fi Protocol stack. This feature allows the application program to run without having to worry too much about how much execution time will be needed to handle the incoming/outgoing Wi-Fi data stream (which is hard to reliably predict, due to its asynchronous nature).

However, in addition to the dual cores, the ESP32 is also blessed with many unique peripheral blocks—most of which operate at a high level and thus require little or no MCU intervention during normal operation. This makes it much easier to write code for projects that have time-critical I/O operations. To appreciate the versatility of the ESP32’s peripheral function blocks, you have to dig into its Technical Reference Manual (TRM). At less than 600 pages, the ESP32’s TRM is somewhat leaner than most new 32-bit MCUs, so I didn’t mind studying it.

The ESP32 has been integrated into the Arduino IDE, and therefore Arduino
Wi-Fi, webserver, web client and UDP client libraries are available. I’ve done a few ESP32 Wi-Fi projects using these libraries, and found them to be straightforward. With all that in mind, in this article I am going to concentrate on three peripheral blocks that I consider to be very powerful and useful. I’ll present some code examples and custom libraries that I have written that make use of these peripherals—sometimes in ways that are different from their intended use).

The three peripheral blocks that I’ll be covering are:

  1. The Remote Control peripheral
  2. The Pulse Counter peripheral
  3. The LEDC controller peripheral

I’ll also briefly discuss the I2S and DAC/Cosine Generator blocks and provide some routines that enable you to generate some useful signals using these blocks.
The most serious work being done with the ESP32 centers on Espressif’s own IDF/C toolchain. But many people prefer to use the Arduino libraries developed for the ESP32, because they are accustomed to using it with many different MCUs—like AVR, ARM and ESP8266/32. Personally, I use the Visual Micro add-in to Visual Studio. It provides a much more professional development environment, while still using the Arduino tool-chain “under the hood.” All references to library files/folders or sample programs can be found on Circuit Cellar’s article materials webpage.

.*
TedsWoodworking Plans and Projects


Remote Controller Peripheral

This peripheral is rather unique among the MCUs that I have encountered. Its function is twofold:

  1. Transmitting IR signals such as used by IR remote controls
  2. Receiving IR signals from IR remote controls

IR remotes don’t send data in the same way that UARTs, SPI and I2C ports do. In other words, they don’t structure the data with each bit taking a specific amount of time. Instead, a “1” bit will consist of a burst of IR light for a specific time, followed by a specific period of no light. A “0” bit will define different periods of time for either the IR pulse, the space or sometimes both. To complicate matters, the IR light pulses are always amplitude modulated by some carrier frequency (in the 25-60 kHz range)..

Read the full article in the March 332 issue of Circuit Cellar

Don’t miss out on upcoming issues of Circuit Cellar. Subscribe today!

Original article and pictures take http://circuitcellar.com/cc-blog/exploring-the-esp32s-peripheral-blocks/?utm_campaign=website&utm_medium=link&utm_source=pinterest site

Комментариев нет:

Отправить комментарий