5秒后页面跳转
AN197 PDF预览

AN197

更新时间: 2022-04-23 23:00:11
品牌 Logo 应用领域
芯科 - SILICON 通信
页数 文件大小 规格书
14页 234K
描述
SERIAL COMMUNICATIONS GUIDE FOR THE CP210X

AN197 数据手册

 浏览型号AN197的Datasheet PDF文件第2页浏览型号AN197的Datasheet PDF文件第3页浏览型号AN197的Datasheet PDF文件第4页浏览型号AN197的Datasheet PDF文件第5页浏览型号AN197的Datasheet PDF文件第6页浏览型号AN197的Datasheet PDF文件第7页 
AN197  
SERIAL COMMUNICATIONS GUIDE FOR THE CP210X  
Relevant Devices  
This application note applies to the following devices:  
CP2101, CP2102, CP2103  
1. Introduction  
This document is intended for developers creating products based on the CP210x USB to UART Bridge Controller.  
It provides information about serial communications and how to obtain the port number for a specific CP210x  
device. Code samples are provided for opening, closing, configuring, reading, and writing to a COM port. Also  
included are GetPortNumWinXXXX() functions that can be copied and used to determine the port number on a  
CP210x device by using its Vendor ID (VID), Product ID (PID), and serial number.  
2. Opening a COM Port  
Before configuring and using a COM port to send and receive data, it must first be opened. When a COM port is  
opened, a handle is returned by the CreateFile() function that is used from then on for all communication. Here is  
example code that opens COM3:  
HANDLE hMasterCOM = CreateFile("\\\\.\\COM3",  
GENERIC_READ | GENERIC_WRITE,  
0,  
0,  
OPEN_EXISTING,  
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,  
0);  
The first parameter in the CreateFile() function is a string that contains the COM port number to use. This string will  
always be of the form "\\\\.\\COMX" where X is the COM port number to use. The second parameter contains flags  
describing access, which will be GENERIC_READ and GENERIC_WRITE for the example in this document, and  
allows both read and write access. Parameters three and four must always be 0, and the flag in parameter five  
must always be OPEN_EXISTING when using CreateFile() for COM applications. The sixth parameter should  
always contain the FILE_ATTRIBUTE_NORMAL flag. In addition, the FILE_FLAG_OVERLAPPED is an optional  
flag that is used when working with asynchronous transfers (this option is used for the example in this document).  
If overlapped mode is used, functions that read and write to the COM port must specify an OVERLAPPED  
structure identifying the file pointer, which is demonstrated in section 3.1. and section 3.2. (more information on  
overlapped I/O is located at http://msdn.microsoft.com/library/en-us/dnfiles/html/msdn_serial.asp?frame=true -  
serial_topic4). The seventh, and last, parameter must always be 0.  
If this function returns successfully, then a handle to the COM port will be assigned to the HANDLE variable. If the  
function fails, then INVALID_HANDLE_VALUE will be returned. Upon return check the handle and if it's valid, then  
prepare the COM port for data transmission.  
Rev. 0.6 10/07  
Copyright © 2007 by Silicon Laboratories  
AN197  

与AN197相关器件

型号 品牌 描述 获取价格 数据表
AN1979 FREESCALE Altimeter and Barometer System

获取价格

AN1984 FREESCALE Handling Freescale Pressure Sensors

获取价格

AN1A3Q NEC On-Chip Resistor PNP Silicon Epitaxial Transistor

获取价格

AN1A4M NEC PNP SILICON TRANSISTOR

获取价格

AN1A4P NEC PNP SILICON TRANSISTOR

获取价格

AN1A4P-A RENESAS AN1A4P-A

获取价格