EmbeddedRelated.com
Forums

USB for embedded controller

Started by dyrl February 29, 2012
On Fri, 02 Mar 2012 09:46:22 -0700, hamilton <hamilton@nothere.com>
wrote:

>On 3/1/2012 11:48 PM, upsidedown@downunder.com wrote: >> On Thu, 01 Mar 2012 09:04:06 -0700, hamilton<hamilton@nothere.com> >> wrote: >> >>> >>> Too many people use "RS-232" too mean async-serial. >>> >>> The RS-232 spec only addresses the voltage levels presented to the >>> interface, not any speed. >>> >>> With that said, 625Kbaud in just as valid as "standard" values. >>> >>> Many of the newer USB to Serial chips can go as fast as 920Kbaud. >>> >>> >>> The biggest problem is getting windows to select a speed that is not a >>> "standard" speed. ( I am sure this is leftover from the modem days ) >> >> Those "standard" speeds are typically multiples of 2 and hence a >> single crystal at say 16 times the highest bit rate is used. To >> generate a lower speed, simply insert a number of divide by 2 >> frequency dividers between the oscillator and the UART. >> >> To generate "non-standard" bit rates, you at least would have to use a >> programmable divide by N integer divider and hope that Fcrystal/N will >> fall within 1-2 % of the desired bit rate. Of course, this is quite >> unlikely for high bit rates, in which N is quite small. >> >> To get closer to a desired frequency, some fractional (dual modulus) >> approaches or PLLs would have to be used. Do these USB to serial >> converters contain dual modulo or PLL clock generators ? >> > >This is fine for an embedded processor where you have direct control of >the baud rate registers. > >On PCs, Windozes or Linux, you do not have access to the baud rate >registers. > >Standard terminal programs have a list of baud rates to select from. > >As you say, multiples of 2. > >Some PC programming languages have the ability to get just about any >strange baud rate you want, but most people do not know this. > >Just like the term "RS-232", the CDC profile needs a baud rate to init >the USB "serial port". But the truth is USB knows no baud rate, its only >at the hardware serial port of the USB peripheral chip that this number >is actually used.
While the Win32 API provides a standard set of values for the baud rate (CBR_1200, CBR_9600, etc.), it's just a 32 bit field in the DCB, and you can set a specific baud rate other than the ones with standard definitions. The actual interpretation is left to the device driver. But the standard CBR values are not really powers of two in any sense. Much original hardware used a divider that divided a clock (1.843MHz) by some multiple of 16*. So the original serial ports could be programmed for 115,200 baud by setting the divisor to 1. You'd get 57600 with a divisor of two, but rates like 9600 or 19,200 required non-power of two divisors (12 or 6). Nor did 110 ever work out quite right (but close enough of async serial communications). And Windows supplies "standard" values of CBR_128000 and CBR_256000, which don't fit the pattern at all. Of course many applications that can drive a serial port only present a fixed set of choices. Often those lists are slightly odd - Windows's Hyperterminal, for example, included 230,400 and 460,800, which don't have standard CBR_ definitions, as choices, but not the 128,000 or 256,000 values. Also many device driver only implement the standard values, even if the hardware they're supporting can handle other values. *The most common async receiver technique sampled the signal 16 times per bit - and while other techniques were occasionally used, the 16 times sampling was used on dozens, if not hundreds of UART designs, including the 8250 and its successors using in hundreds of millions of PCs.