|
|
RS232 Protocol for the NIOS Board
This app note is specifically for RS232 requirements for the NIOS board as well as to clear up some points that have not been made clear in previous app notes.
RS232 Setup and Packet Transfer
None. Unlike other implementations documented for the UP1 board and other boards, the NIOS board has a serial header which does not require any external circuitry to function.
To clear up any confusion. In the serial stream, the earlier the bit arrives, the less significant it is. The code will take the LSB of the 8 bit set of data bits in the packet and assign it to bit 0 in the 24 bit stream to ram. Likewise the last bit in the packet will be the MSB and assigned accordingly.
Connecting the PC (DTE) to the FPGA (DCE)
The DB9 diagram is shown on the DCE end which we are more concerned with
DB-9 |
|
Pin 2 - Received Data (RxD) This signal is active when the DTE device receives data from the DCE device. When no data is transmitted, the signal is held in the mark condition (logic '1', negative voltage).
NOTE: Pin 2 on the DTE device is commonly labeled "Transmitted Data"
Pin 3 - Transmitted Data (TxD) This signal is active when data is transmitted from the DTE device to the DCE device. When no data is transmitted, the signal is held in the mark condition (logic '1', negative voltage).
NOTE: Pin 3 on the DTE device is commonly labeled "Received Data"
.
Pin 7 - Request to Send (RTS) This signal is asserted (logic '0', positive voltage) to prepare the DCE device for accepting transmitted data from the DTE device. Such preparation might include enabling the receive circuits, or setting up the channel direction in half-duplex applications. When the DCE is ready, it acknowledges by asserting Clear to Send. This signal does not need to be implemented to have a properly functioning RS232 interface provided all you are doing is recieving data; however, should a full implementation be required, you may need to concern yourself with this signal.
Pin 8 - Clear to Send (CTS)
This signal is asserted (logic '0', positive voltage)
by the DCE device to inform the DTE device that transmission may
begin. RTS and CTS are commonly used as handshaking signals to
moderate the flow of data into the DCE device.
Software Support
To send files to the NIOS board via RS232, use MTTTY. It is a rather flexible program which would be able to implement further improvements to the code such as parity. Crashes occasionally. Get it here
Setting up MTTTY, RS232 Data and Clock Dividers
Clock dividers for the NIOS board had to be recalculated for the 33.33GHz clock from the previous values to match certain baud rates. They are: 109 for recieving data and 1736 for sending (send code will have to be obtained from a different group (ie NN Trainer).
Also, using MTTTY, it was found that the data is received more reliably when 2 stop bits are used rather than a single stop bit. As the code looks for a 10 bit data packet and does not begin the loop again until a new start bit is found, the second stop bit allows a slight buffer to ensure everything is in the required state. This is not a neccesity but it seems to help.
Implemented Code
RS232 In
RS232 Out
References
The RS232 Connection
Christopher E.
Strangio
Copyright © 1993-1997 by CAMI Research Inc.,
Lexington, Massachusetts
http://www.camiresearch.com/Data_Com_Basics/RS232_standard.html
RS232 Serial Port
Tim Bensler & Eric Chan
http://www.ee.ualberta.ca/~elliott/ee552/studentAppNotes/1999_w/RS232
|
|