Hello Friends,
Today is sunday I have got time to Hack UART and make my driver and application with linux.So lets start
Interfacing the Serial/RS232 Port
Introduction
-The Serial Port is harder to interface than the Parallel Port.
Advantages of serial communication over parallel communication
- Serial Cables can be longer than Parallel cables. The serial port transmits a '1'
as -3 to -25 volts and a '0' as +3 to +25 volts where as a parallel port
transmits a '0' as 0v and a '1' as 5v. Therefore cable loss is not going to be as much of a problem for serial cables than they are for parallel.
- You don't need as many wires than parallel transmission
-Microcontroller have built in serial communication interface.Hence it reduces the number for pin.In serial communication there are only transmitter and recevier.
PART-1
Hardware(PC) Properties:
-Devices which use serial cables for their communication have two categories
1)DCE(data communication equipment)e.g modem, TA adapter, plotter etc
2)DTE(data terminal equipment)e.g Computer or Terminal.
Electrical specification of serial port in RS232C standard
1)A "Space" (logic 0) will be between +3 and +25 Volts.
2.A "Mark" (Logic 1) will be between -3 and -25 Volts.
3.The region between +3 and -3 volts is undefined.
4.An open circuit voltage should never exceed 25 volts. (In Reference to
GND)
5.A short circuit current should not exceed 500mA. The driver should be
able to handle this without damage. (Take note of this one!)
-serial port comes in 2 sizes 9 and 25 pin
D-type-25 pin no. D-type-9 Pin No. Abbreviation
pin2 pin3 TD transmit data
pin3 pin2 RD receive data
pin4 pin7 RTS request to send
pin5 pin8 CTS clear to send
pin6 pin6 DSR data set ready
pin7 pin5 SG signal ground
pin8 pin1 CD carrier detect
pin20 pin4 DTR data terminal ready
pin22 pin9 RI ring indicator
TD-serial data output
RD-serial data input
CTS-this line indiacates that modem is ready to exchange data
DCD-when modem detects a "carrier" from the modem at the other end of phone line, this line becomes active
DSR-this tell the UART that the modem is ready to establish a link.
DTR-this tell the modem that the UART is ready to establish a link.
RTS- this informs the modem that the UART is ready to exchange data
RI-goes active when modem detects a ringing signal from the PSTN.
Null Modem:
DTE / DCE Speeds:
-People may talk about DTE-DTE speed and DCE-DTE speed
DCE-DTE speed between your modem and computer,sometimes refereed to as your terminal speed
-This runs faster than DCE-DCE speed is link between between modem knows as line speed
-Today most of modem should have data compression build into them .This has compression ratio of 1:4.
Thus this is why the DCE-DTE should be much higher than your modem's connection speed.
Flow Control
-Software flow control, sometimes expressed as Xon/Xoff uses two characters Xon and Xoff
-This type of flow control has the advantage that it doesn't require any more wires as the characters are sent via the TD/RD lines.
-However on slow links each character requires 10 bits which can slow communications down.
-Hardware flow control is also known as RTS/CTS flow control.
-Thus hardware flow control will not slow down transmission times like Xon-Xoff does. When the computer wishes to send data it takes active the Request to Send line. If the modem has room for this data, then the modem will reply by taking active the Clear to Send line and the computer starts sending data.
Types of UARTS (For PC's)
8250First UART in this series. It contains no scratch register. The 8250A was an
improved version of the 8250 which operates faster on the bus side.
8250A
This UART is faster than the 8250 on the bus side. Looks exactly the same to
software than 16450.
8250B
Very similar to that of the 8250 UART.
16450
Used in AT's (Improved bus speed over 8250's). Operates comfortably at
38.4KBPS. Still quite common today.
16550
This was the first generation of buffered UART. It has a 16 byte buffer, however it
doesn't work and is replaced with the 16550A.
16550A
Is the most common UART use for high speed communications eg 14.4K &
28.8K Modems. They made sure the FIFO buffers worked on this UART.
16650
Very recent breed of UART. Contains a 32 byte FIFO, Programmable X-On / X-
Off characters and supports power management.
16750
Produced by Texas Instruments. Contains a 64 byte FIFO.
Part-2:Serial Port's Register(PC's)
Name Address IRQ
COM 1 3F8 4
COM 2 2F8 3
COM 3 3E8 4
COM 4 2E8 3
-Just like the LPT ports, the base addresses for the COM ports can be read from the BIOS Data Area.
Start Address Function
0000:0400 COM1's Base Address
0000:0402 COM2's Base Address
0000:0404 COM3's Base Address
0000:0406 COM4's Base Address
Transmitter Holding Buffer
Receiver Buffer
Interrupt Enable Register
Divisor Latch High Byte
Interrupt Identification Register
FIFO Control Register
Line Control Register
Modem Control Register
Line Status Register
Modem Status Register
Scratch Register
Communication
You can always make a user space program for communication of two computer with each other via UART cable.
Two commands are used for configuring UART in computer
1]setserial
2]stty
Study both command with man pages
Some command
$setserial -g /dev/ttys0
$setserial /dev/ttys0 uart 16550A
$echo "hello" > /dev/ttys0
$cat /dev/ttys0
stty -F /dev/ttys0 cstopb -cs8 raw -parenb ispeed 9600
Today is sunday I have got time to Hack UART and make my driver and application with linux.So lets start
Interfacing the Serial/RS232 Port
Introduction
-The Serial Port is harder to interface than the Parallel Port.
Advantages of serial communication over parallel communication
- Serial Cables can be longer than Parallel cables. The serial port transmits a '1'
as -3 to -25 volts and a '0' as +3 to +25 volts where as a parallel port
transmits a '0' as 0v and a '1' as 5v. Therefore cable loss is not going to be as much of a problem for serial cables than they are for parallel.
- You don't need as many wires than parallel transmission
-Microcontroller have built in serial communication interface.Hence it reduces the number for pin.In serial communication there are only transmitter and recevier.
PART-1
Hardware(PC) Properties:
-Devices which use serial cables for their communication have two categories
1)DCE(data communication equipment)e.g modem, TA adapter, plotter etc
2)DTE(data terminal equipment)e.g Computer or Terminal.
Electrical specification of serial port in RS232C standard
1)A "Space" (logic 0) will be between +3 and +25 Volts.
2.A "Mark" (Logic 1) will be between -3 and -25 Volts.
3.The region between +3 and -3 volts is undefined.
4.An open circuit voltage should never exceed 25 volts. (In Reference to
GND)
5.A short circuit current should not exceed 500mA. The driver should be
able to handle this without damage. (Take note of this one!)
-serial port comes in 2 sizes 9 and 25 pin
D-type-25 pin no. D-type-9 Pin No. Abbreviation
pin2 pin3 TD transmit data
pin3 pin2 RD receive data
pin4 pin7 RTS request to send
pin5 pin8 CTS clear to send
pin6 pin6 DSR data set ready
pin7 pin5 SG signal ground
pin8 pin1 CD carrier detect
pin20 pin4 DTR data terminal ready
pin22 pin9 RI ring indicator
TD-serial data output
RD-serial data input
CTS-this line indiacates that modem is ready to exchange data
DCD-when modem detects a "carrier" from the modem at the other end of phone line, this line becomes active
DSR-this tell the UART that the modem is ready to establish a link.
DTR-this tell the modem that the UART is ready to establish a link.
RTS- this informs the modem that the UART is ready to exchange data
RI-goes active when modem detects a ringing signal from the PSTN.
Null Modem:
DTE / DCE Speeds:
-People may talk about DTE-DTE speed and DCE-DTE speed
DCE-DTE speed between your modem and computer,sometimes refereed to as your terminal speed
-This runs faster than DCE-DCE speed is link between between modem knows as line speed
-Today most of modem should have data compression build into them .This has compression ratio of 1:4.
Thus this is why the DCE-DTE should be much higher than your modem's connection speed.
Flow Control
-Software flow control, sometimes expressed as Xon/Xoff uses two characters Xon and Xoff
-This type of flow control has the advantage that it doesn't require any more wires as the characters are sent via the TD/RD lines.
-However on slow links each character requires 10 bits which can slow communications down.
-Hardware flow control is also known as RTS/CTS flow control.
-Thus hardware flow control will not slow down transmission times like Xon-Xoff does. When the computer wishes to send data it takes active the Request to Send line. If the modem has room for this data, then the modem will reply by taking active the Clear to Send line and the computer starts sending data.
Types of UARTS (For PC's)
8250First UART in this series. It contains no scratch register. The 8250A was an
improved version of the 8250 which operates faster on the bus side.
8250A
This UART is faster than the 8250 on the bus side. Looks exactly the same to
software than 16450.
8250B
Very similar to that of the 8250 UART.
16450
Used in AT's (Improved bus speed over 8250's). Operates comfortably at
38.4KBPS. Still quite common today.
16550
This was the first generation of buffered UART. It has a 16 byte buffer, however it
doesn't work and is replaced with the 16550A.
16550A
Is the most common UART use for high speed communications eg 14.4K &
28.8K Modems. They made sure the FIFO buffers worked on this UART.
16650
Very recent breed of UART. Contains a 32 byte FIFO, Programmable X-On / X-
Off characters and supports power management.
16750
Produced by Texas Instruments. Contains a 64 byte FIFO.
Part-2:Serial Port's Register(PC's)
Name Address IRQ
COM 1 3F8 4
COM 2 2F8 3
COM 3 3E8 4
COM 4 2E8 3
-Just like the LPT ports, the base addresses for the COM ports can be read from the BIOS Data Area.
Start Address Function
0000:0400 COM1's Base Address
0000:0402 COM2's Base Address
0000:0404 COM3's Base Address
0000:0406 COM4's Base Address
Transmitter Holding Buffer
Receiver Buffer
Interrupt Enable Register
Divisor Latch High Byte
Interrupt Identification Register
FIFO Control Register
Line Control Register
Modem Control Register
Line Status Register
Modem Status Register
Scratch Register
Communication
You can always make a user space program for communication of two computer with each other via UART cable.
Two commands are used for configuring UART in computer
1]setserial
2]stty
Study both command with man pages
Some command
$setserial -g /dev/ttys0
$setserial /dev/ttys0 uart 16550A
$echo "hello" > /dev/ttys0
$cat /dev/ttys0
stty -F /dev/ttys0 cstopb -cs8 raw -parenb ispeed 9600
No comments:
Post a Comment