SC16IS750 I2C or SPI to UART bridge

This page describes the NXP SC16IS750 I2C or SPI to UART bridge. The device provides a UART serial port that may be controlled through an I2C or SPI port. Typical use would be to add (one or more) serial ports to an mbed. The SC16IS750 is a slave device to the mbed controller. It has internal registers that can be accessed to control the behaviour of the UART and that may be used to read or write data that is available on the serial port. Some of its features:

  • Single full-duplex UART
  • Selectable I2C-bus or SPI interface
  • 3.3 V or 2.5 V operation
  • 64 bytes FIFO (transmitter and receiver)
  • Fully compatible with industrial standard 16C450 and equivalent
  • Baud rates up to 5 Mbit/s in 16x clock mode
  • Auto hardware flow control using RTS/CTS
  • Auto software flow control with programmable Xon/Xoff characters
  • Single or double Xon/Xoff characters
  • Automatic RS-485 support (automatic slave address detection)

Details may be found in the NXP datasheet.

The library has been extended with support for the SC16IS752 Dual UART bridge and an option for a hardware reset pin. (22 Dec 2014)

Hardware

The device is available in several (tiny) packages. The most practical way of using the component is by connecting mbed to a breakout board for the device. Sparkfun provides this BOB for about $15 as productnumber 9981.

/media/uploads/wim/09981-04b2.jpg

Note that there are also some marginally cheaper ''clones'' available on ebay and other webstores. One of the reasons to start working on a library for the device was that it is also used on the Sparkfun WiFly shield. More about that later...

Here is a blockdiagram of the device when wired as a SPI-UART bridge:

/media/uploads/wim/block1.jpg

Note that full UART flowcontrol (RTS/CTS etc) is supported. In that case some of the pins of the 8-Bit General Purpose I/O port are no longer available for other purposes.

The test set-up consisted of an mbed KL25Z, the breakout board, some LEDs for the IO port and a USB-Serial converter that connects the SC16IS750 serial port to a terminal application on the PC. The KL25Z is also connected to the PC by USB and its own terminal application. That results in two separate terminal windows that can be used for bidirectional communication loops.

Here is a picture of the test system...

/media/uploads/wim/img_3158.jpg The LEDs are for debugging. The small black box is the Serial to USB converter used to interface with the serial port of the bridge device.

Wiring table

Sparkfun SC16IS750KL25ZFTDI 232LEDs
p1 IO3ncncC1
p2 IO4ncncC2
p3 IO5ncncC3
p4 IO6ncncC4
p5 IO7ncncC5
p6 RTSncp2 CTSnc
p7 CTSncp6 RTSnc
p8 TXncp5 RXnc
p9 RXncp4 TXnc
p10 RESETncncnc
p11 GNDGNDp1 GNDnc
p12 I2C/SPIGNDp1 GNDnc
p13 A0/CSPTD0ncnc
p14 A1/SIPTD2ncnc
p15 NC/SOPTD3ncnc
p16 SCL/SCKPTD1ncnc
p17 SDA/VSSGNDp1 GNDnc
p18 IRQncncnc
p19 IO0ncncC0
p20 IO1ncncC1
p21 IO2ncncC2
p22 VINVDD 3V3ncAnodes + R

Note1: The LEDs are for debugging purposes. Use a common anode with serial resistors to each LED.

Note2: The FTDI 232 USB to Serial converter MUST be a 3V3 type. The standard pinout for the 6 pin connector is used in the table above.

Library

The Sparkfun site provides a library for the arduino [see Ref below]. The lib only supports the SPI interface and does not use several of the device features. The arduino lib served as inspiration for the mbed library.The objective was to develop an API for the serial bridge that closely matches the mbed Serial class to allow an easy switch between a 'native' serial port and the serial bridge.

Import librarySC16IS750

SPI or I2C to UART Bridge

Example Code

// SC16IS750_SPI for a converter between SPI and a Serial port
#include "mbed.h"
#include "SC16IS750.h"

SPI spi(PTD2, PTD3, PTD1); //MOSI, MISO, SCK
SC16IS750_SPI serial_bridge(&spi, PTD0);  // SPI port and CS pin
 
Serial pc(USBTX,USBRX);

int main() {
  pc.printf("\nHello World!\n");

  serial_bridge.baud(9600);
  //serial_bridge.printf("\nHello World!\n"); // supported through Stream
  
  while(1) { 
    serial_bridge.ioSetState(0x00);
    wait(0.5);
    serial_bridge.ioSetState(0xFF); 
    wait(0.5); 
    serial_bridge.putc('*');  
    pc.putc('*');                
  }
}

Example Test software

Import programmbed_SC16IS750

Test for SC16IS750 and SC16IS752 I2C or SPI to UART bridge.

Future Work

Some additional features could be added. For example IrDa support or full Interrupt support. We will see what's useful... Obviously, the main reason to start working on a library for the device was that it is also used on the Sparkfun WiFly shield. The near term objective is to get that working by combining the mbed WiFlyInterface with the SC16IS750 library. More about that later...

References


Please log in to post comments.