CP2102 its high integration, built-in USB2.0 full-speed function controller, USB transceiver, crystal oscillator, EEPROM, and asynchronous serial data bus (UART), supports full-featured modem signals, without any external USB device. CP2102 with other USB-UART adapter circuit works similar to the PC through the driver's USB port into a virtual COM port in order to achieve the purpose of expansion.
- Uses the CP2102 USB to UART controller
- Windows, Mac, and Linux Compatible
- 5V and 3.3V Operation
Quick Start with Teensy 2.0
- Wiring: The CP210c module can be connected either a 5V or 3.3V logic level UART serial port. This example will detail the wiring for a Teensy 2.0 microcontroller. Unique to this PCB implementation of the CP2102 is both a 5V and 3.3V output. Both outputs are only rated of low currents (less than 100mA) but it can be very useful for powering a small system from a USB port. For this example the CP210x module will be used to power the Teensy 2.0 at 5V after programming.
To wire the system, connect a common ground between the CP210x module and the Teensy 2.0. Common grounds must always be used for communication systems to allow for reliable signal transfer. The Teensy 2.0 has two dedicated UART serial pins located on PORT D, pins 2 and 3. Be aware that when using UART serial, the transmit (TXD) pin of the microcontroller should be connected to the receive (RX) pin of the CP2102. The receive (RXD) of the microcontroller then goes to the transmit (TX) pin of the CP2012. Finally since the CP210x module will power the Teensy, connect the 5V pin of the CP210x to the 5V pin of the Teensy 2.0.
- After wiring the unit, you can download the C example code below. This code is tested to compile via avr-gcc under Windows and Linux. You may need to install the avr-gcc compiler prior to using these files. A pre-compiled .hex file is included for rapid use. There is a cp210x.h and cp210x.c file included in the example. The code initializes the hardware UART on the Teensy 2.0 and transmits "Hello World" repeatedly over the UART port at a baudrate of 34800. The protocol is set up for 8 data bits, no parity, and one stop bit (8N1). As an example, the user can enter a letter back to the Teensy over the serial port and see a change in response.
CP210x USB to UART Teensy 2.0 Sample Code
- The sample code can be compiled from the command-line via the command 'make all' and downloaded to a Teensy 2.0 with the command 'make program' in windows. The Makefile does not currently support download automatically to Linux or Mac machines. If you have one of these platforms, download the loader from the Teensy 2.0 website and program the hex that way.
- To be able to fully use a serial (UART) port on a computer a 'terminal program' should be employed. One suggested program for Windows based systems isTermite (Local Copy). Termite is a versatile tool allowing for display and entry of both ASCII characters and raw hex values. Additionally, most operating system installs will need to download and install a driver for the CP210x family of USB to UART devices. These can be downloaded directly from Silicon Labsor local but older versions for Windows , Mac, or Linux (3.x.x). Driver installation will vary system to system but often only involves a simple installer utility. Consult Silicon Labs support if help is needed.
Please note in the image below, the configuration of Termite is shown for communicating with this example code. However the 'Port' setting for each computer may vary. For this example the operating system chose COM4. On many machines it may be COM1 or COM2. To find the com port to be used in Windows open the Windows 'Device Manager' and look under the 'Ports' section of the devices list.