18.1 Xtensa LX6 Microprocessor
In around 2010, Tensilica Company of USA developed a 32-bit customizable (re-configurable) microprocessor, and it was named Xtensa LX (Fig-18.1). It is not a fixed function MPU like 8086; rather, it contains many extra hardware blocks (marked as … and Optional Functional Units in Fig-18.2) which can be activated at product design time to add more functions to the basic Xtensa.
18.2 ESP32 Microcontroller
In 2013, Cadence Design Systems of USA acquired Tensilica. In 2016, Espressif Systems Company of China borrowed the MPU from Cadence and built the ESP32 Microcontroller (MCU) chip (Fig-18.3).
The MCU has 48 pins and some pins have one or more signals/functions; whereas, Fig-18.4 shows the default pin signals/functions. For the example of alternate functions, see Section-18.9.
The MCU contains the following resources within the same 48-pin package:
(1) Two pieces (Cores) of LX6 MPU,
(2) 440 KB Mask ROM,
(3) 520 KB RAM,
(4) 8 KB RTC Fast Memory,
(5) 8 KB RTC Slow Memory, and
(6) A large number of peripheral controllers and devices (Fig-18.5).
18.3 ESP-WROOM-32 Module
It is a 38-pin small PCB (Fig-18.6) which contains the following hardware resources covered by a Metallic Box/RF Shield. Body of the Metallic Box is a GND-pin, and it is counted as Pin-39.
(1) ESP32 MCU,
(2) 48 MHz Crystal for the MCU,
(3) 4 MB SPI Port based Serial Flash Memory, and
(4) PCB-based combined antenna for Bluetooth and WiFi.
Under the Metallic Cover (Radio Frequency Shield) of Fig-18.6, there are devices like (shown in Fig-18.7): ESP32 MCU, Flash Memory, 40 MHz crystal, and some resistors/capacitors.
The ESP32 has 48 signals/pins, flash memory has 8 signals/pins, and the ESP-WROOM-32 Module (Fig-18.8) has 38 signals/pins. The mappings/connections of pin signals among ESP32, flash, and ESP-WROOM_32 Module are depicted in Fig-18.12.
18.4 ESP32 Dev Module
It is a 30-pin Learning and Development Board (known as ESP32 Dev Module, Fig-18.9). It is built around ESP-WROOM-32 Module. There is only 30-pin in the Module; so, many functions of the root ESP32 MCU (Fig-18.4) are not available to the user. Fig-18.13 of Section-18.6 shows the pin mappings among 48-pin ESP32 MCU, 38-pin ESP-WROMM-32 Module, and 30-pin ESP32 Dev Module.
Once the Board is installed and ESP32 Dev Module is selected, the following Libraries are automatically included in the Arduino IDE. Sketch can be created/uploaded like Arduino UNO.
(1) ESP-IDF (IoT Development Framework) Library from Espressif Company
(2) FreeRTOS Library from Real Time Engineers Ltd.
Figure-19.9
Logic Level and Current Ratings of the Module Pins: This is a 3.3V Board which means that the logic levels are 0V (LOW) and 3.3V (HIGH). Any connection with a 5V device must be through level shifter; otherwise, one or both boards will be damaged. Each pin of the board is rated for 40 mA source and sink current; but, the recommendation is not to exceed 20 mA.
VIN: If not powering the Board from PC, then feed 7V – 12V at VIN-pin. It will be converted to 3.3V by the onboard regulator. The 3.3V regulator can reliably supply up to 600mA. The ESP32 can pull as much as 250mA during RF transmissions, but generally it consumes around 150mA -- even with active WiFi.
The mappings/connections of the 30-pins of the ESP32 Dev Module and ESP-WROOM-32 Module are shown in Fig-18.13.
18.5 Alternate Functions of Pin-25 and Pin-27 of ESP32 MCU
In Fig-18.4 (pin diagram), it is observed that Pin-25 and Pin-27 of the ESP32 MCU are labeled as GPIO16 (General Purpose Input/Output Line 16) and GPIO17 respectively. Fig-18.10 (data sheet) and Fig-18.11 indicate that GPIO16/Pin-25 and GPIO17/Pin-27 lines can be connected with one of five peripheral modules of the MCU. These Modules are: Digital IO Interface, High Speed 1 Interface, UART2 Interface, EMAC (Ethernet Media Access Control) Module, and PWM Module.
(1) By default, SW5 is closed; as a result, digital IO lines (IO16 and IO17) are connected with Pin-25 and Pin-27 as GPIO16 and GPIO17. These two signals have appeared as D16 and D17 on the header pins of ESP32 Dev Module (Fig-18.8). Now if we connect a LED with D16-pin of Fig-18.8 and upload the following sketch, the LED will turn ON.
Void setup()
{
pinMode(D16, OUTPUT);
digitalWrite(D16, HIGH);
}
Void loop(){}
(2) If the following code is executed, SW5 of Fig-18.10 will be opened and SW3 will be closed; as a result, D16/D17 pins of ESP32 Dev Module (Fig-18.8) will be working as UART2 Port.
Serial2.begin(9600);
(3) If we wish that D16/D17 of ESP32 Dev Module will work as digital IO lines and UART2 Interface’s signal be routed to other free digital pines (say, D18/RX2 and D19/TX2), then we may execute the following codes. The SW5 remains closed, SW3 remains open, and SW6 gets closed.
Serial2.begin(115200, SERIAL_8N1, 18, 19); //Bd, Character=8-bit, No-parity, 1-Stop bit, RX2, TX2
(4) Likewise, Serial1 UART1 Interface can be routed to free DPins like D5(RX1) and D18(TX1). The code is:
Serial1.begin(115200, SERIAL_8N1, 5, 18); //Bd, Character=8-bit, No-parity, 1-Stop bit, RX1, TX1
(5) UART1 Interface can even be routed to D1(RX0) and D5(TX0) for quick check of the functioning of UART1 Port by exchanging message with Serial Monitor which is connected with UART0 Port (Fig-18.11). The code is:
Serial1.begin(115200, SERIAL_8N1, 3, 1); //Bd, Character=8-bit, No-parity, 1-Stop bit, RX1, TX1
Test Sketch:
void setup()
{
Serial1.begin(115200, SERIAL_8N1, 3, 1); //RX0, TX0
delay(100);
Serial1.println("Hello frtom Serial1 !!");
}
void loop()
{
delay(1000);
Serial1.println("and again ..");
}
When the above sketch is executed, SW1 gets opened and SW2 gets closed. Now, the signals of UART1 Module are connected with Serial Monitor via TTL/USB Converted depicted in Fig-18.11.