Connection to PADI via UART interface

The UART interface is one of the first external computer interfaces that was already used in the first self-assembled computers as a COM port (RS232, is still in use). It would be strange if PADI did not have at least one such interface, and it has as many as 3!
49678deb1134e9ed1fc504570f44fcfb

The UART interface is one of the first external computer interfaces that was already used in the first self-assembled computers as a COM port (RS232, is still in use). It would be strange if PADI did not have at least one such interface, and it has as many as 3! We will talk about working with them today.

THEORY
UART – asynchronous interface. If, in the same SPI and I2C, the device understands when to read a new bit, exclusively on the clock edge, then here the delay between two readings/shipments is calculated within the devices themselves, and, naturally, must be the same for correct data reception.

This is the difficulty – for correct operation, a few more bits are included in the data packet, so the UART transmission rate (measured in baud, that is, “bits per second”) cannot simply be divided by 8 and the speed in data bytes per second — one the minimum byte will be stretched to 10 bits due to the start bit and stop bit.

Often, in addition to these necessary bits, add even parity bits to ensure validation of the data, and there can also be 2 pieces of stop bits. This slows down the transmission, but makes it more reliable; The RS-232 standard allows transmission of 15 meters at a speed of 115200 baud (maximum standardized speed).

To implement the project from this article, we need the following components:

  • PADI IoT Stamp – WiFi module based on RTL8710AF
  • PADI Breadboard Adapter – Breadboard Adapter
  • CP2102 – USB-UART programmer
  • Breadboard (400 points)
  • Connecting wires

 CONNECTION
The RTL8710 has 2 UART interfaces operating at the highest possible speed and one low-speed interface supporting the sleep of the main core (with minimal consumption).

By default, the Serial object works with the UART, which is located on GB0 (TXD) and GB1 (RXD).

To communicate with a PC, you must use a special adapter. If you have a hardware COM port (to check this, remove all USB-UART converters and open Device Manager – if the COM1 port exists, then there is a hardware COM port and its connector is located behind the system unit), then you can use RS232-UART a converter that simply builds on transistors or a MAX232 chip:

 

But a universal solution would be a USB-UART adapter, such as ours, based on the CP2102:

 It is compatible with all popular operating systems (no drivers are needed for Linux) and supports all standard operating frequencies. For non-standard frequencies, it is recommended to use the CP2104 – it has auto-sensing speed.

When powering PADI and adapter from one computer, all you need to do is connect the RX and TX lines. With a separate power supply, it is necessary to bind both the adapter and the module ground.

Important – connection of data lines UART cross – RX to TX, TX to RX!

To track the flow on a PC, you can use both the built-in Arduino IDE terminal and third-party applications, such as Terminal by Br @@ y – supports managing service lines of the port and many frequencies, but in today’s article we will not go beyond the built-in terminal.

So, let’s start working with transferring data from PADI. Included with the Ameba package are many examples of working with wireless networks. Almost all output information to the serial port. For example, open the sketch AmebaWiFi-ScanNetworks and load it into PADI:

 

 Data successfully received! If you look closely at the text of the program, you will see that the port is configured at a speed of 9600 baud, and we accept at 38400 without any errors!

Unfortunately, this is still an uncorrected error in the adaptation code of the controller for the Arduino IDE – no matter what speed you set, transmission and reception will be carried out at 38,400 baud. This does not allow us to connect, for example, an RFID module or LC12S, which operates at a frequency of 9600 baud. We hope that in future versions this will be fixed.

You can use a Serial object to access this port, so all standard Arduino examples will also work. Sketch ASCIITable from standard examples in the Communication folder:

 

Share on facebook
Facebook
Share on google
Google+
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on pinterest
Pinterest