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.
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:
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...
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 SC16IS750 | KL25Z | FTDI 232 | LEDs |
---|---|---|---|
p1 IO3 | nc | nc | C1 |
p2 IO4 | nc | nc | C2 |
p3 IO5 | nc | nc | C3 |
p4 IO6 | nc | nc | C4 |
p5 IO7 | nc | nc | C5 |
p6 RTS | nc | p2 CTS | nc |
p7 CTS | nc | p6 RTS | nc |
p8 TX | nc | p5 RX | nc |
p9 RX | nc | p4 TX | nc |
p10 RESET | nc | nc | nc |
p11 GND | GND | p1 GND | nc |
p12 I2C/SPI | GND | p1 GND | nc |
p13 A0/CS | PTD0 | nc | nc |
p14 A1/SI | PTD2 | nc | nc |
p15 NC/SO | PTD3 | nc | nc |
p16 SCL/SCK | PTD1 | nc | nc |
p17 SDA/VSS | GND | p1 GND | nc |
p18 IRQ | nc | nc | nc |
p19 IO0 | nc | nc | C0 |
p20 IO1 | nc | nc | C1 |
p21 IO2 | nc | nc | C2 |
p22 VIN | VDD 3V3 | nc | Anodes + 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
- Datasheet SC16IS750 NXP datasheet
- Sparkfun Breakout Board productnumber 9981.
- Sparkfun WiFly Shield code library
- Switch Science R1350N gyro module with SC16IS750
Please log in to post comments.