Beginner
10 min

Achieve both data transformation and isolation for enhanced safety with FT232RL and PIC24EP512GU814

Bridge the gap between USB and UART

USB UART 4 Click with UNI Clicker

Published Nov 07, 2023

Click board™

USB UART 4 Click

Dev Board

UNI Clicker

Compiler

NECTO Studio

MCU

PIC24EP512GU814

Elevate your USB communication to a whole new level with our isolated UART transformation, guarding your equipment against electrical disturbances

A

A

Hardware Overview

How does it work?

USB UART 4 Click is based on the FT232RL, a USB to UART interface IC, from FTDI. The entire USB protocol is handled on the IC itself, thus no USB specific firmware programming is required. FTDI provides royalty-free Virtual Com Port (VCP) and Direct (D2XX) drivers for all the major OSes, used on personal computers. FT232RL also contains an integrated 1024 Bit internal EEPROM for storing USB VID, PID, serial number, product description strings and CBUS I/O configuration. The Baud Rate Generator provides a 16x clock input to the UART Controller from the 48MHz reference clock. It consists of a 14-bit pre-scaler and 3 register bits which provide fine tuning of the baud rate - used to divide by a number plus a fraction. This determines the baud rate of the UART, which is programmable from 183 baud to 3 Mbaud. Also, non-standard baud rates are supported. The baud rate is automatically calculated by the FTDI driver, so it is enough to simply forward the desired baud rate to the driver, usually done by selecting the baud rate via the GUI interface of the PC terminal application. After installing the OS drivers, the device is ready to be used. When plugged in, it will create a virtual COM port. After that, it can be used

with the USART Terminal application, included in every mikroE compiler. It can be used for the data exchange between the MCU and the host computer. This device also features the configurable CBUS pins, which can be used for several different useful functions, as for example - configurable clock out for driving the microcontroller, data LED drive, USB Sleep, PWR status and so on. By default, CBUS3 and CBUS4 pins are configured as Power Enable and Sleep options and are routed to the PWM and RST pins of the mikroBUS™, respectively. More information about configuring the CBUS pins can be found in the FT232RL datasheet. CBUS3 output pin (PWM pin of the mikroBUS™) will be set to a LOW logic state during the USB suspend mode It can be used to power down external circuitry or be used for similar purposes. CBUS4 output pin (RST pin of the mikroBUS™) will be set to a LOW logic state after the device has been configured by the USB, then HIGH during the USB suspend mode. This can also be used for the powering down/power saving, by turning unneeded external circuitry. This device also supports two additional signals - RTS (Request To Send) and CTS (Clear To Send),

which can be used when the hardware flow control is required. USB UART click also features a small low noise LDO, used to provide the logic voltage level reference. The input voltage for the LDO is taken from the USB or the mikroBUS™ 5V rail. The 3.3V rail from the LDO output is routed to the SMD jumper. It allows selection of the referent voltage for the logic section of the FT232RL, thus making possible to interface the USB UART click to both 3.3V and 5V MCUs. The UART communication is indicated by two LEDs, red for TX (sending data in UART to USB direction) and yellow for RX (receiving data in USB to UART direction). These LEDs are used to provide a visual indication if there is any data transfer ongoing. One feature worth mentioning is this Click board™ specific shape - it is made so that it can be plugged directly into the USB Type A port. It doesn’t have a conventional USB connector, but the PCB is shaped so that the USB traces can be connected to the USB port. Since the FT232RL supports the unique serial number feature, this makes it handy for developing data protection devices and dongles of various kinds. However, it can also be used in a traditional way.

USB UART 4 Click hardware overview image

Features overview

Development board

UNI Clicker is a compact development board designed as a complete solution that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It supports a wide range of microcontrollers, such as different ARM, PIC32, dsPIC, PIC, and AVR from various vendors like Microchip, ST, NXP, and TI (regardless of their number of pins), four mikroBUS™ sockets for Click board™ connectivity, a USB connector, LED indicators, buttons, a debugger/programmer connector, and two 26-pin headers for interfacing with external electronics. Thanks to innovative manufacturing technology, it allows you to build

gadgets with unique functionalities and features quickly. Each part of the UNI Clicker development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the UNI Clicker programming method, using a third-party programmer or CODEGRIP/mikroProg connected to onboard JTAG/SWD header, the UNI Clicker board also includes a clean and regulated power supply module for the development kit. It provides two ways of board-powering; through the USB Type-C (USB-C) connector, where onboard voltage regulators provide the appropriate voltage levels to each component on the board, or using a Li-Po/Li

Ion battery via an onboard battery connector. All communication methods that mikroBUS™ itself supports are on this board (plus USB HOST/DEVICE), including the well-established mikroBUS™ socket, a standardized socket for the MCU card (SiBRAIN standard), and several user-configurable buttons and LED indicators. UNI Clicker is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

UNI clicker double image

Microcontroller Overview

MCU Card / MCU

default

Type

8th Generation

Architecture

dsPIC

MCU Memory (KB)

512

Silicon Vendor

Microchip

Pin count

144

RAM (Bytes)

53248

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Sleep / CBUS4
RJ5
RST
UART CTS
RJ4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Power Enable / CBUS3
RF0
PWM
UART RTS
RA14
INT
UART TX
RF1
TX
UART RX
RA15
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

USB UART 4 Click Schematic schematic

Step by step

Project assembly

UNI Clicker front image hardware assembly

Start by selecting your development board and Click board™. Begin with the UNI Clicker as your development board.

UNI Clicker front image hardware assembly
GNSS2 Click front image hardware assembly
SiBRAIN for STM32F745VG front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
UNI Clicker 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 image step 5 hardware assembly
Necto image step 6 hardware assembly
Necto image step 7 hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output

After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.

Application Output Step 1

After programming is completed, a header with buttons for various actions available in the IDE appears. By clicking the green "PLAY "button, we start reading the results achieved with Click board™.

Application Output Step 3

Upon completion of programming, the Application Output tab is automatically opened, where the achieved result can be read. In case of an inability to perform the Debug function, check if a proper connection between the MCU used by the setup and the CODEGRIP programmer has been established. A detailed explanation of the CODEGRIP-board connection can be found in the CODEGRIP User Manual. Please find it in the RESOURCES section.

Application Output Step 4

Software Support

Library Description

This library contains API for USB UART 4 Click driver.

Key functions:

  • usbuart4_pwr_ctrl - This function sets the click turns click on.

  • usbuart4_set_cts - This function sets CTS pin.

  • usbuart4_send_command - This function is used for sending commands.

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 USB UART 4 Click Example.
 *
 *# Description
 * This example reads and processes data from USB UART 4 clicks.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes driver and power module.
 * 
 * ## Application Task  
 * Reads data and echos it back to device and logs it to board.
 *
 * @author Stefan Ilic
 *
 */

#include "board.h"
#include "log.h"
#include "usbuart4.h"
#include "string.h"

#define PROCESS_BUFFER_SIZE 500

static usbuart4_t usbuart4;
static log_t logger;

static char app_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;

void application_init ( void ) {
    log_cfg_t log_cfg;  /**< Logger config object. */
    usbuart4_cfg_t usbuart4_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 " );
    Delay_ms( 100 );

    // Click initialization.

    usbuart4_cfg_setup( &usbuart4_cfg );
    USBUART4_MAP_MIKROBUS( usbuart4_cfg, MIKROBUS_1 );
    
    err_t init_flag  = usbuart4_init( &usbuart4, &usbuart4_cfg );
    if ( UART_ERROR == init_flag ) {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }

    app_buf_len = 0;
    
    usbuart4_pwr_ctrl( &usbuart4, USBUART4_POWER_ON );
    usbuart4_set_cts( &usbuart4, USBUART4_CTS_NO_ACTIVE );
    usbuart4_set_mode( &usbuart4, USBUART4_MODE_NORMAL );
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) {
    app_buf_len = usbuart4_generic_read( &usbuart4, app_buf, PROCESS_BUFFER_SIZE );
    
    if ( app_buf_len > 0 ) {
        log_printf( &logger, "%s", app_buf );
        memset( app_buf, 0, PROCESS_BUFFER_SIZE );
    }
}

void main ( void ) {
    application_init( );

    for ( ; ; ) {
        application_task( );
    }
}

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

Additional Support

Resources