Intermediate
30 min

Build a reliable serial communication system with SP3221E and TM4C123GH6PZ

The ultimate wingman for your communication needs

RS232 3 Click with UNI-DS v8

Published Apr 18, 2023

Click board™

RS232 3 Click

Dev Board

UNI-DS v8

Compiler

NECTO Studio

MCU

TM4C123GH6PZ

Maximize your serial communication with the reliable and low-power RS232 transceiver

A

A

Hardware Overview

How does it work?

RS232 3 Click is based on the SP3221E, a low-power, RS232 transceiver (single driver/single receiver) solution with a 250kbps data rate from MaxLinear. The SP3221E uses an internal high-efficiency, charge-pump power supply and complies with EIA/TIA-232-F standards when powered by any of the mikroBUS™ power rails. This charge pump and MaxLinear's driver architecture allow the SP3221E to deliver compliant RS-232 performance from a single power supply intended for portable or handheld applications such as embedded computers, data logging devices, medical diagnostics, and remote sensors. The SP3221E communicates with MCU using the UART interface with the default baud rate of 115200bps for data transfer. It also comes equipped with the standard DB-9 connector, which makes interfacing with the RS232 simple and easy,

and a red LED indicator labeled STATUS that indicates whether a valid RS232 signal is present. This signal is also routed to the INT pin of the mikroBUS™ socket, labeled as STA. Alongside UART communication, several signals connected to the mikroBUS™ socket pins are also used to forward the information to the MCU. For proper operation of SP3221E, this board uses a combination of EN and SHD pins, routed to the default place of the CS and RST pins of the mikroBUS™ socket. The receiver is active when the AUTO ON-LINE® circuitry is enabled or in Shutdown. The AUTO ON-LINE® feature, controlled via the ON pin routed to the PWM pin of the mikroBUS™ socket, allows the SP3221E to automatically "Wake-Up" from a Shutdown state when an RS232 cable is connected and a peripheral device is turned on.

During the Shutdown, the receiver will continue to be active. The device goes into Standby mode if there is no activity at the receiver for a more extended period or when the SHD pin is enabled. Also, driving the EN pin to a high state forces the receiver's output into a high impedance state. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. However, the Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used, as a reference, for further development.

RS232 3 Click top side image
RS232 3 Click lateral side image
RS232 3 Click bottom side image

Features overview

Development board

UNI-DS v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports a wide range of microcontrollers, such as different STM32, Kinetis, TIVA, CEC, MSP, PIC, dsPIC, PIC32, and AVR MCUs regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer over WiFi. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, UNI-DS v8 provides a fluid and immersive working experience, allowing access anywhere and under any

circumstances at any time. Each part of the UNI-DS v8 development board contains the components necessary for the most efficient operation of the same board. An advanced integrated CODEGRIP programmer/debugger module offers many valuable programming/debugging options, including support for JTAG, SWD, and SWO Trace (Single Wire Output)), and seamless integration with the Mikroe software environment. Besides, it also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector. Communication options such as USB-UART, USB

HOST/DEVICE, CAN (on the MCU card, if supported), and Ethernet is also included. In addition, it also has the well-established mikroBUS™ standard, a standardized socket for the MCU card (SiBRAIN standard), and two display options for the TFT board line of products and character-based LCD. UNI-DS v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

UNI-DS v8 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Type

8th Generation

Architecture

ARM Cortex-M4

MCU Memory (KB)

256

Silicon Vendor

Texas Instruments

Pin count

100

RAM (Bytes)

32768

You complete me!

Accessories

DB9 Cable Female-to-Female (2m) cable is essential for establishing dependable serial data connections between devices. With its DB9 female connectors on both ends, this cable enables a seamless link between various equipment, such as computers, routers, switches, and other serial devices. Measuring 2 meters in length, it offers flexibility in arranging your setup without compromising data transmission quality. Crafted with precision, this cable ensures consistent and reliable data exchange, making it suitable for industrial applications, office environments, and home setups. Whether configuring networking equipment, accessing console ports, or utilizing serial peripherals, this cable's durable construction and robust connectors guarantee a stable connection. Simplify your data communication needs with the 2m DB9 female-to-female cable, an efficient solution designed to meet your serial connectivity requirements easily and efficiently.

RS232 3 Click accessories image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Shutdown
PH0
RST
Enable
PF7
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
AUTO ON-LINE®
PF5
PWM
RS232 Signal Status
PH4
INT
UART TX
PC7
TX
UART RX
PC6
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

RS232 3 Click Schematic schematic

Step by step

Project assembly

Fusion for PIC v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the UNI-DS v8 as your development board.

Fusion for PIC v8 front image hardware assembly
GNSS2 Click front image hardware assembly
SiBRAIN for PIC32MZ1024EFK144 front image hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
v8 SiBRAIN Access MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
NECTO Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

Track your results in real time

Application Output via UART Mode

1. Once the code example is loaded, pressing the "FLASH" button initiates the build process, and programs it on the created setup.

2. After the programming is completed, click on the Tools icon in the upper-right panel, and select the UART Terminal.

3. After opening the UART Terminal tab, first check the baud rate setting in the Options menu (default is 115200). If this parameter is correct, activate the terminal by clicking the "CONNECT" button.

4. Now terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART_Application_Output

Software Support

Library Description

This library contains API for RS232 3 Click driver.

Key functions:

  • rs2323_generic_write This function writes a desired number of data bytes by using UART serial interface.

  • rs2323_generic_read This function reads a desired number of data bytes by using UART serial interface.

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

/*!
 * @file main.c
 * @brief RS232 3 Click Example.
 *
 * # Description
 * This example demonstrates the use of an RS232 3 click board by showing
 * the communication between the two click board configured as a receiver and transmitter.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and logger and displays the selected application mode.
 *
 * ## Application Task
 * Depending on the selected mode, it reads all the received data or 
 * sends the desired message every 3 seconds.
 * 
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "rs2323.h"

// Comment out the line below in order to switch the application mode to receiver
#define DEMO_APP_TRANSMITTER

#define DEMO_TEXT_MESSAGE           "MikroE - RS232 3 click board\r\n"

static rs2323_t rs2323;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    rs2323_cfg_t rs2323_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    rs2323_cfg_setup( &rs2323_cfg );
    RS2323_MAP_MIKROBUS( rs2323_cfg, MIKROBUS_1 );
    if ( UART_ERROR == rs2323_init( &rs2323, &rs2323_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
#ifdef DEMO_APP_TRANSMITTER
    log_printf( &logger, " Application Mode: Transmitter\r\n" );
#else
    log_printf( &logger, " Application Mode: Receiver\r\n" );
#endif   
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
#ifdef DEMO_APP_TRANSMITTER
    rs2323_generic_write( &rs2323, DEMO_TEXT_MESSAGE, strlen( DEMO_TEXT_MESSAGE ) );
    log_printf( &logger, "%s", ( char * ) DEMO_TEXT_MESSAGE );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 ); 
#else
    uint8_t rx_data;
    if ( rs2323_generic_read( &rs2323, &rx_data, 1 ) > 0 )
    {
        log_printf( &logger, "%c", rx_data );
    }
#endif
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.