Our isolation innovation simplifies secure data transfer, offering an easy-to-use bridge for UART to RS232 connections while providing a secure and reliable communication channel
A
A
Hardware Overview
How does it work?
RS232 Isolator 2 Click is based on the ICL3221, a 3.3V powered RS232 transmitter/receiver that provides ±15kV ESD protection on its RS232 pins from Renesas. It features an automatic power-down function that occurs when the RS232 cable is removed and conserves system power automatically and power-up again when a valid RS232 voltage is applied to any receiver input. It also ensures data rates greater than 250kbps, even at worst-case load conditions. This Click board™ represents an isolated RS232 interface configuration using PS9121, an optically coupled high-speed active low-type isolator from Renesas, containing a GaAlAs LED on the input side, a photodiode, and a signal processing circuit on the output side rated for 3.75kV isolation and up to
15Mbps data rate. The RS232 transceiver ICL3221 is specified with a data rate of 250kbps and operates from a 3.0V to 3.6V external power supply header on the board's right side. In addition to the optocouplers, the TC7SZ125FU logic buffers from Toshiba Semiconductor are used to drive the necessary LED currents that usually cannot be provided by low-power MCUs or RS232 receiver outputs. The ICL3221 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 diode indicator labeled INVALID indicates whether a valid RS232 signal is present. This diode always indicates whether a
valid RS232 signal is present at any of the receiver inputs, giving the user a way to determine when the interface block should power down. If the interface cable is disconnected from the DB-9 connector and all the receiver inputs are floating, the ICL3221 detects invalid levels by turning the LED. Reconnecting the cable restores valid levels at the receiver inputs, the diode turns off, and the power management logic wakes up the interface block. This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used as a reference for further development.
Features overview
Development board
Curiosity HPC, standing for Curiosity High Pin Count (HPC) development board, supports 28- and 40-pin 8-bit PIC MCUs specially designed by Microchip for the needs of rapid development of embedded applications. This board has two unique PDIP sockets, surrounded by dual-row expansion headers, allowing connectivity to all pins on the populated PIC MCUs. It also contains a powerful onboard PICkit™ (PKOB), eliminating the need for an external programming/debugging tool, two mikroBUS™ sockets for Click board™ connectivity, a USB connector, a set of indicator LEDs, push button switches and a variable potentiometer. All
these features allow you to combine the strength of Microchip and Mikroe and create custom electronic solutions more efficiently than ever. Each part of the Curiosity HPC development board contains the components necessary for the most efficient operation of the same board. An integrated onboard PICkit™ (PKOB) allows low-voltage programming and in-circuit debugging for all supported devices. When used with the MPLAB® X Integrated Development Environment (IDE, version 3.0 or higher) or MPLAB® Xpress IDE, in-circuit debugging allows users to run, modify, and troubleshoot their custom software and hardware
quickly without the need for additional debugging tools. Besides, it includes a clean and regulated power supply block for the development board via the USB Micro-B connector, alongside all communication methods that mikroBUS™ itself supports. Curiosity HPC development board allows you to create a new application in just a few steps. Natively supported by Microchip software tools, it covers many aspects of prototyping thanks to many number of different Click boards™ (over a thousand boards), the number of which is growing daily.
Microcontroller Overview
MCU Card / MCU
Architecture
PIC
MCU Memory (KB)
24
Silicon Vendor
Microchip
Pin count
28
RAM (Bytes)
2048
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.
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output via Debug Mode
1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.
2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.
Software Support
Library Description
This library contains API for RS232 Isolator 2 Click driver.
Key functions:
rs232isolator2_generic_write
- RS232 Isolator 2 data writing function.rs232isolator2_generic_read
- RS232 Isolator 2 data reading function.rs232isolator2_send_data
- RS232 Isolator 2 data writing 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 RS232 Isolator 2 Click Example.
*
* # Description
* This library contains API for RS 232 Isolator 2 Click driver.
* This example transmits/receives and processes data from RS 232 Isolator 2 clicks.
* The library initializes and defines the UART bus drivers
* to transmit or receive data.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes driver and wake-up module.
*
* ## Application Task
* Transmitter/Receiver task depend on uncommented code.
* Receiver logging each received byte to the UART for data logging,
* while transmitted send messages every 2 seconds.
*
* ## Additional Function
* - static void rs232isolator2_clear_app_buf ( void ) - Function clears memory of app_buf.
* - static err_t rs232isolator2_process ( void ) - The general process of collecting presponce
* that a module sends.
*
* @author Nenad Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "rs232isolator2.h"
#define PROCESS_BUFFER_SIZE 200
#define TRANSMITTER
// #define RECIEVER
static rs232isolator2_t rs232isolator2;
static log_t logger;
static char app_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;
static int32_t app_buf_cnt = 0;
unsigned char demo_message[ 9 ] = { 'M', 'i', 'k', 'r', 'o', 'E', 13, 10, 0 };
/**
* @brief RS 232 Isolator 2 clearing application buffer.
* @details This function clears memory of application buffer and reset it's length and counter.
* @note None.
*/
static void rs232isolator2_clear_app_buf ( void );
/**
* @brief RS 232 Isolator 2 data reading function.
* @details This function reads data from device and concats data to application buffer.
*
* @return @li @c 0 - Read some data.
* @li @c -1 - Nothing is read.
* @li @c -2 - Application buffer overflow.
*
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t rs232isolator2_process ( void );
void application_init ( void ) {
log_cfg_t log_cfg; /**< Logger config object. */
rs232isolator2_cfg_t rs232isolator2_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.
rs232isolator2_cfg_setup( &rs232isolator2_cfg );
RS232ISOLATOR2_MAP_MIKROBUS( rs232isolator2_cfg, MIKROBUS_1 );
err_t init_flag = rs232isolator2_init( &rs232isolator2, &rs232isolator2_cfg );
if ( init_flag == UART_ERROR ) {
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
app_buf_len = 0;
app_buf_cnt = 0;
log_info( &logger, " Application Task " );
#ifdef TRANSMITTER
log_printf( &logger, " Send data: \r\n" );
log_printf( &logger, " mikroE \r\n" );
log_printf( &logger, "------------------\r\n" );
log_printf( &logger, " Transmit data \r\n" );
Delay_ms ( 1000 );
#endif
#ifdef RECIEVER
log_printf( &logger, " Receive data \r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#endif
log_printf( &logger, "------------------\r\n" );
}
void application_task ( void ) {
#ifdef TRANSMITTER
rs232isolator2_send_data( &rs232isolator2, demo_message );
log_printf( &logger, "%s", demo_message );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
log_printf( &logger, "------------------\r\n" );
#endif
#ifdef RECIEVER
rs232isolator2_process( );
if ( app_buf_len > 0 ) {
log_printf( &logger, "%s", app_buf );
rs232isolator2_clear_app_buf( );
}
#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;
}
static void rs232isolator2_clear_app_buf ( void ) {
memset( app_buf, 0, app_buf_len );
app_buf_len = 0;
app_buf_cnt = 0;
}
static err_t rs232isolator2_process ( void ) {
int32_t rx_size;
char rx_buff[ PROCESS_BUFFER_SIZE ] = { 0 };
rx_size = rs232isolator2_generic_read( &rs232isolator2, rx_buff, PROCESS_BUFFER_SIZE );
if ( rx_size > 0 ) {
int32_t buf_cnt = 0;
if ( app_buf_len + rx_size >= PROCESS_BUFFER_SIZE ) {
rs232isolator2_clear_app_buf( );
return RS232ISOLATOR2_ERROR;
} else {
buf_cnt = app_buf_len;
app_buf_len += rx_size;
}
for ( int32_t rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ ) {
if ( rx_buff[ rx_cnt ] != 0 ) {
app_buf[ ( buf_cnt + rx_cnt ) ] = rx_buff[ rx_cnt ];
} else {
app_buf_len--;
}
}
return RS232ISOLATOR2_OK;
}
return RS232ISOLATOR2_ERROR;
}
// ------------------------------------------------------------------------ END