5秒后页面跳转
AN197 PDF预览

AN197

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

AN197 数据手册

 浏览型号AN197的Datasheet PDF文件第8页浏览型号AN197的Datasheet PDF文件第9页浏览型号AN197的Datasheet PDF文件第10页浏览型号AN197的Datasheet PDF文件第12页浏览型号AN197的Datasheet PDF文件第13页浏览型号AN197的Datasheet PDF文件第14页 
AN197  
8. Application Design Notes  
The functions used in section 3., section 4., and section 5. are Windows COMM API functions. The examples  
provided are just samples of the recommended way of dealing with serial communication. For more specific  
information on these functions, see the MSDN website at: http://msdn.microsoft.com/library/default.asp.  
It should also be noted that the SetCommState() function does not save the settings between opening and closing  
the COM port. As stated before, it is good practice to get the current settings after the COM port is opened, and  
then restore them before it is closed.  
All of the functions here will return an error code. It is a good idea to nest these functions in order to catch errors if  
they occur by using the GetLastError() function. This will also solve any surprise removal problems by allowing the  
discovery of an invalid handle to be found and dealt with. The example application (CP210xSerialTest) has several  
cases that will detect surprise removal. In this example, there are checks on every function to make sure that the  
return code is true. If it is not, then it will display where the error occurred in the output window. As long as correct  
and supported settings are passed to the functions they should execute normally. Most failures can occur from  
having an INVALID_HANDLE_VALUE, however, the handles must be set to this value after a surprise removal  
occurs.  
Because regular COM ports will always be visible, then data can always be written to them successfully, even if  
there is no way to read it. However, because the CP210x is a virtual COM port, if the device is removed, then the  
handle that it uses becomes invalid when trying to write to it. If for some reason the CP210x device is unplugged  
the write will fail and ERROR_OPERATION_ABORTED will be returned by GetLastError(). When this happens, the  
handle needs to be closed and then set to INVALID_HANDLE_VALUE. Alternatively, a regular COM port can  
always be read from, but if there is no data then it will time out. When using the CP210x as the virtual COM port  
and it is removed before a read occurs, then the read will fail and ERROR_ACCESS_DENIED will be returned by  
GetLastError(). Again when this happens, the handle needs to be closed and then set to  
INVALID_HANDLE_VALUE.  
9. References  
MSDN - use this to search for specific Windows API functions  
http://msdn.microsoft.com/  
Serial Communication Reference  
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp  
Communication Resource Reference  
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/communications_resources.asp  
Rev. 0.6  
11  

与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

获取价格