Empower your projects with dynamic UART control – our solution lets you redirect your data flow on the fly, offering a new level of adaptability to suit your project’s communication demands.
A
A
Hardware Overview
How does it work?
UART MUX 4 Click is based on the 74HC4066D, a quad single-pole, single-throw analog switch from Nexperia. The CMOS level inputs of the 74HC4066D include clamp diodes, which in turn allow the use of current limiting resistors to interface inputs to voltages exceeding VCC. This Click board™ has two multiplexed 4-pin UART headers labeled UART1 and UART2. The UART header lines are labeled for corresponding pins. It
offers fast switching speeds with a turn-off time of 13ns and 11ns for turn-on if powered with 5V. The UART MUX 2 Click uses a standard UART interface to communicate with the host MCU, with commonly used RX and TX lines. To switch between the two output UART interfaces, this Click board™ features a switch in the form of an NPN transistor circuit. This switch circuit allows the use of one of the outputs UART interfaces via the
SW pin of the mikroBUS™ socket with a simple logic 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. Also, this 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.
Features overview
Development board
EasyPIC PRO v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports many high pin count 8-bit PIC microcontrollers from Microchip, 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, EasyPIC PRO v8 provides a fluid and immersive working experience, allowing access anywhere and under
any circumstances at any time. Each part of the EasyPIC PRO v8 development board contains the components necessary for the most efficient operation of the same board. In addition to the advanced integrated CODEGRIP programmer/debugger module, which offers many valuable programming/debugging options and seamless integration with the Mikroe software environment, the board 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 DEVICE, and Ethernet are also included, including the well-established mikroBUS™ standard, a standardized socket for the MCU card (SiBRAIN standard), and two display options (graphical and character-based LCD). EasyPIC PRO 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.
Microcontroller Overview
MCU Card / MCU
Type
8th Generation
Architecture
PIC
MCU Memory (KB)
32
Silicon Vendor
Microchip
Pin count
80
RAM (Bytes)
2048
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project 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.
Software Support
Library Description
This library contains API for UART MUX 4 Click driver.
Key functions:
uartmux4_enable_uart1
- UART MUX 4 enable the UART 1 function.uartmux4_enable_uart2
- UART MUX 4 enable the UART 2 function.
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 UART MUX 4 Click Example.
*
* # Description
* This example demonstrates the use of UART MUX 4 click board by processing
* the incoming data and displaying them on the USB UART.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the UART driver and additional pins.
*
* ## Application Task
* Writes demo message, echos it back, processes all incoming data
* and displays them on the USB UART.
*
* @author Nenad Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "uartmux4.h"
#define PROCESS_BUFFER_SIZE 200
#define DEMO_MESSAGE "\r\nMikroE\r\n"
static uartmux4_t uartmux4;
static log_t logger;
static uint8_t app_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
uartmux4_cfg_t uartmux4_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.
uartmux4_cfg_setup( &uartmux4_cfg );
UARTMUX4_MAP_MIKROBUS( uartmux4_cfg, MIKROBUS_1 );
if ( UART_ERROR == uartmux4_init( &uartmux4, &uartmux4_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
Delay_ms( 100 );
}
void application_task ( void )
{
log_printf( &logger, " ---------------- \r\n" );
log_printf( &logger, " UART 1 demo message:\r\n" );
uartmux4_enable_uart1( &uartmux4 );
Delay_ms( 100 );
for ( uint8_t n_cnt = 0; n_cnt < 5; n_cnt++ )
{
if ( uartmux4_generic_write ( &uartmux4, DEMO_MESSAGE, sizeof( DEMO_MESSAGE ) ) )
{
if ( uartmux4_generic_read( &uartmux4, app_buf, sizeof( DEMO_MESSAGE ) ) )
{
log_printf( &logger, "%s", app_buf );
}
}
Delay_ms( 2000 );
}
log_printf( &logger, " ---------------- \r\n" );
log_printf( &logger, " UART 2 demo message:\r\n" );
uartmux4_enable_uart2( &uartmux4 );
Delay_ms( 100 );
for ( uint8_t n_cnt = 0; n_cnt < 5; n_cnt++ )
{
if ( uartmux4_generic_write ( &uartmux4, DEMO_MESSAGE, sizeof( DEMO_MESSAGE ) ) )
{
if ( uartmux4_generic_read( &uartmux4, app_buf, sizeof( DEMO_MESSAGE ) ) )
{
log_printf( &logger, "%s", app_buf );
}
}
Delay_ms( 2000 );
}
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END