开发者

How to Set Baud Rate 28800 Using DCB Structure

开发者 https://www.devze.com 2022-12-16 19:56 出处:网络
Previously I was using CBR_9600 when communicating with 9600 bau开发者_运维百科d devices. But there does not seem to be a CBR_28800 setting. Is it possible to set the baud rate using the DCB structure

Previously I was using CBR_9600 when communicating with 9600 bau开发者_运维百科d devices. But there does not seem to be a CBR_28800 setting. Is it possible to set the baud rate using the DCB structure of 28800?


According to MSDN, the baud rate can either be one of the defined constants (such as CBR_9600, CBR_38400, etc) or any integer value. The constants are just defined to the values, so it's not really an enumeration at all. From the link:

The baud rate at which the communications device operates. This member can be an actual baud rate value, or one of the following indexes.


Yes. CBR_9600 is just equal to 9600. It should be possible to plug in 28800 and it will just work.


Note that if you use rates other then the "standard" rates, the actual rate may differ from the target rate. In the hardware a "baud rate divisor" register divides down a master clock to achieve the desired baud rate, so a finite number of discrete values are available. However the resolution available at low rates is high; the increments get larger at low divisor values.

This can be a problem if communicating with devices that use different UART hardware and clocking than the PC, because the resultant rate differences can in extreme cases be beyond specified tolerances.

0

精彩评论

暂无评论...
验证码 换一张
取 消