Serial Programming - upload.wikimedia....
Serial Programming - upload.wikimedia....
Serial Programming - upload.wikimedia....
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
8250 UART <strong>Programming</strong><br />
LCR_Offset = $03;<br />
Latch_Low = $00;<br />
Latch_High = $01;<br />
procedure SetBaudRate(NewRate: Word);<br />
var<br />
DivisorLatch: Word;<br />
begin<br />
DivisorLatch := 115200 div NewRate;<br />
Port[COM1_Base + LCR_Offset] := Port[COM1_Base + LCR_Offset] or<br />
$80; {Set DLAB}<br />
Port[COM1_Base + Latch_High] := DivisorLatch shr 8;<br />
Port[COM1_Base + Latch_Low] := DivisorLatch and $FF;<br />
Port[COM1_Base + LCR_Offset] := Port[COM1_Base + LCR_Offset] and<br />
$7F; {Clear DLAB}<br />
end;<br />
function GetBaudRate: Integer;<br />
var<br />
DivisorLatch: Word;<br />
begin<br />
Port[COM1_Base + LCR_Offset] := Port[COM1_Base + LCR_Offset] or<br />
$80; {Set DLAB}<br />
DivisorLatch := (Port[COM1_Base + Latch_High] shl 8) +<br />
Port[COM1_Base + Latch_Low];<br />
Port[COM1_Base + LCR_Offset] := Port[COM1_Base + LCR_Offset] and<br />
$7F; {Clear DLAB}<br />
Result := 115200 div DivisorLatch;<br />
end;<br />
3.6.3 Interrupt Enable Register<br />
Offset: +1 . This register allows you to control when and how the UART is going to trigger<br />
an interrupt event with the hardware interrupt associated with the serial COM port. If<br />
used properly, this can enable an efficient use of system resources and allow you to react<br />
to information being sent across a serial data line in essentially real-time conditions. Some<br />
more on that will be covered later, but the point here is that you can use the UART to let<br />
you know exactly when you need to extract some data. This register has both read- and<br />
write-access.<br />
The following is a table showing each bit in this register and what events that it will enable<br />
to allow you check on the status of this chip:<br />
Interrupt Enable Register (IER)<br />
Bit Notes<br />
7 Reserved<br />
6 Reserved<br />
5 Enables Low Power Mode (16750)<br />
4 Enables Sleep Mode (16750)<br />
3 Enable Modem Status Interrupt<br />
2 Enable Receiver Line Status Interrupt<br />
1 Enable Transmitter Holding Register Empty Interrupt<br />
0 Enable Received Data Available Interrupt<br />
40