Beruflich Dokumente
Kultur Dokumente
The RS-232 serial communication protocol is a standard protocol used in asynchronous 232 serial communication. Figure 1 shows the relationship between the various components in a serial ink
Figure 1 : Asynchronous (RS-232) serial link The components are the UART, the serial channel, and the interface logic , An interface chip known as the universal asynchronous receiver/transmitter or UART is used to implement serial data transmission transmission. The UART sits between the host computer and the serial channel
FRAME FORMAT
A frame is a complete and nondivisible packet of bits A frame includes both information (e.g., data and characters) and overhead (e.g., start bit, error checking and stop bits) In asynchronous serial protocols such as RS-232, the frame consists of one start bit, seven or eight data bits, parity bits, and stop bits.
Figure 2 : RS-232 Frame (1 start bit, 7 data bits, 1 parity bits, and 2 stop bits) The start bit is used to signal the beginning of a frame The stop bit is used to signal the end of a frame Parity is used to detect transmission errors(Even and Odd parity is used) No clock signal is sent through serial line
IMPLEMENTATION ON FPGA
GENERAL RS232 STRUCTURE
Data_in
Uart Transmitter
TXD
Baud Control
sclk
Rate Genrator
FPGA It mainly consisting of a UART Transmitter, UART Receiver, Baud rate generator and a control mechanism UART Transmitter and UART Receiver is used for transmission and reception of data Baud rate generator is used to generate the clock signals for the UART Transmitter and UART Receiver Control mechanism is used to control the data transfer.
1. UART Transmitter
The UART Transmitter accepts the parallel data and converts it into serial data It performs the serializing action on the input data The block diagram is shown below
Data_in 8
1 TXINT
SERIALIZER
TXD
bclk
rst
It accepts the 8-bit data from the data bus and transmits a single bit in a single clock cycle The serializer first converts the 8-bit data into 10-bit by adding start and stop signal to the data bits The serializer is working on the input clock generated by the baud rate generator The transmission is possible only the Transmit Data Register(TDR) is empty After the completion of the transmission UART Transmitter generates an interrupt TXINT. It has a state reset signal to reset the serializer .
SERIALIZER
Data_in
TDR
TSR
TRANSMIT
CONTROL
TXD
SERIALIZER
TDR TSR
TDR is used to hold the input data TSR is used to hold the start, data, and stop bits TSR (0) TSR (1-8) TSR(9) Start bit Data bits Stop bit
SCSR stores the status of the transmitter SCSR(7) TDRE(Transmit Data Register Empty)
If TDRE=1 means TDR contains data and transmission is not possible If TDRE=0 means TDR doesnt contain any data and transmission is possible
sclk
1 IDLE
TDRE
form TSR
SYNCH
sclk
clear TSR(0)
sclk
TXD TSR(Tcnt)
Tcnt=9
2. UART RECEIVER
The UART Receiver accepts the serial data and converts it into parallel data It performs the de-serializing action on the input data The block diagram is shown below
Data_out
RDRF RXINT
DESERIALIZER
RXD
sclk bclk
rst
It accepts the a set single bit from the input and convert it into a parallel(8-bit) data The reception is possible only RDRF signal is low After the reception of the 8-bit data, it generate an interrupt(RXINT) The oversampling method is used to ensure the start and data bits It has a reset signal to reset the system.
OVERSAMPLING METHOD The bit stream coming from the RXD pin is not synchronized with the clock(bclk) If we attempt to read the RXD at the rising edge of bclk we would have a problem if RXD changed near the clock edge We would have a setup and hold time problems
RXD
start bit *
bclkx8
4clock
4 clock
4 clock
DE-SERIALIZER
Data_out
RDR
RSR
RDRF
RECEIVE
RXD
RXINT
CONTROL
bclk
rst SCSR
7 RDRF 5 4 3 2 1 0
DE-SERIALIZER
Receiver Shift Register(8-bit) Receiver Data Register(8-bit) Serial Communication Status Register(8-bit)
RESET
clk
IDLE
RXD
START_DETECT
clkx8
Clear cnt1
RXD
Clear cnt1
Cnt1=3
Inc cnt1
(Contd..)
RXDATA
clkx8
R
Inc cnt1
cnt1=7
Cnt2=8
1
RDR RSR
INTERUPT
Clr cnt2
clk