AN197 Silicon_Laboratories, AN197 Datasheet - Page 3

no-image

AN197

Manufacturer Part Number
AN197
Description
Serial Communications Guide FOR THE Cp210x
Manufacturer
Silicon_Laboratories
Datasheet
AN197
Here a new DCB structure dcbMaster has been initialized to dcbMasterInitState, which are the current settings of
the COM port. After it has been initialized to the current settings, new settings can be assigned.
3.3.1. Baud Rate
The baud rate property is set to 57600 bps, but can be set to any of the baud rates supported by the CP210x. (See
the current data sheet for the list of supported baud rates for the CP210x.)
3.3.2. Parity
The parity is set to NOPARITY, however it can also be set to ODDPARITY, EVENPARITY, SPACEPARITY, and
MARKPARITY if supported by the CP210x. (See the current data sheet for the list of supported parities for the
CP210x.)
3.3.3. Byte Size
The byte size is set to 8, so there are 8 data bits in every byte of data sent. This can also be set to 5, 6, or 7 if
supported by the CP210x. (see the data sheet for the list of supported byte sizes for the CP210x.)
3.3.4. Stop Bits
The stop bits are set to ONESTOPBIT, but could also be set to TWOSTOPBITS or ONE5STOPBITS (1.5). (See the
current data sheet for the list of supported stop bits for the CP210x.) All combinations of data and stop bits can be
used except for the combination of 5 data bits with 2 stop bits and the combination of 6, 7, or 8 data bits with 1.5
stop bits.
After each of these settings is set to the desired value, the SetCommState() function can be called to set up the
COM port. The first parameter in the SetCommState() function is a handle to the open COM port to change the
settings on. The second parameter is an address to a DCB structure containing the COM port's new settings 2
(more information on serial settings using DCB structures is located at
http://msdn.microsoft.com/library/en-us/
dnfiles/html/msdn_serial.asp?frame=true -
serial_topic6).
If this function returns successfully, a non-zero value is returned. If the function fails, it returns 0. Upon return,
check the return value; if it is non-zero, delay for 60 ms to allow time for the settings to change and then continue to
set up the COM port. This delay is not required; however, a conservative time of 60 ms is good practice to ensure
that the settings are changed before any other operations take place.
Rev. 0.6
3

Related parts for AN197