Serial Ports: Difference between revisions
Jump to navigation
Jump to search
→Initialization
[unchecked revision] | [unchecked revision] |
(Category Rename) |
|||
Line 35:
The baud rate is set by writing a divisor value to the UART. The divisor is the fraction of 115200 that makes the baud rate. For instance, the baud rate 57600 would have a divisor of 2.
The number of bits in a character is variable.
The parity type can be even, odd, or none.
Line 52:
}
</pre>
Notice that the initialization code above writes to ports [PORT + 0] and [PORT + 1] twice with different values. The reason for this is because these two ports have different meanings based on the setting of the DLAB (Divisor Latch Access Bit), the most significant bit in [PORT + 3]. When this bit is set, the serial controller maps [PORT + 0] and [PORT + 1] onto the low and high bytes of the Baud Rate Divisor register, and when it is clear they are mapped onto their normal registers.
In the code above, the second write to [PORT + 3] clears the DLAB again as well as setting various other bits.
===Receiving data===
|