Standard Data Frame
The CAN standard data frame is shown in Figure 2-1.
As with all other frames, the frame begins with a Start-
Of-Frame (SOF) bit, which is of the dominant state and
allows hard synchronization of all nodes.
The SOF is followed by the arbitration field, consisting
of 12 bits: the 11-bit identifier and the Remote
Transmission Request (RTR) bit. The RTR bit is used
to distinguish a data frame (RTR bit dominant) from a
remote frame (RTR bit recessive).
Following the arbitration field is the control field,
consisting of six bits. The first bit of this field is the
Identifier Extension (IDE) bit, which must be dominant
to specify a standard frame. The following bit, Reserved
Bit Zero (RB0), is reserved and is defined as a dominant
bit by the CAN protocol. The remaining four bits of the
control field are the Data Length Code (DLC), which
specifies the number of bytes of data (0 – 8 bytes)
contained in the message.
After the control field is the data field, which contains
any data bytes that are being sent, and is of the length
defined by the DLC (0 – 8 bytes).
The Cyclic Redundancy Check (CRC) field follows the
data field and is used to detect transmission errors. The
CRC field consists of a 15-bit CRC sequence, followed
by the recessive CRC Delimiter bit.
The final field is the two-bit Acknowledge (ACK) field.
During the ACK Slot bit, the transmitting node sends
out a recessive bit. Any node that has received an
error-free frame acknowledges the correct reception of
the frame by sending back a dominant bit (regardless
of whether the node is configured to accept that
specific message or not). The recessive acknowledge
delimiter completes the acknowledge field and may not
be overwritten by a dominant bit.
http://ww1.microchip.com/downloads/en/DeviceDoc/21801d.pdf
Correct transmission of the frame is assured by means of the CRC-16 cyclical redundancy check.
Both CRC-16 characters are generated as follows, based upon all of the characters included in the
frame (slave address to last data byte):
1 Presetting of a 16 bit register (CRC-16 register) with FFFFh
2 Exclusive OR linking of the low bytes in the CRC-16 register to the frame’s character,
results to CRC-16 register
3 Shift the CRC-16 register one bit to the right,
A “0“ is added and the displaced, least significant bit (LSB) is saved
4 Where LSB = 0, continue as of step 5.
Where LSB = 1, establish exclusive OR linking of the CRC-16 registers to A001h.
5 Repeat steps 3 and 4 until a total of 8 shifts to the right have occurred.
At this point, one of the frame’s characters has been processed.
6 Execute steps 2 through 5 for each of the frame’s remaining characters.
7 The content of the CRC-16 register, preceded by the low byte, is added to the frame
after all of the frame’s characters have been processed.
programming in C
unsigned int crc_16 (unsigned char *buffer, unsigned int length) {
unsigned int i, j, lsb, tmp, crc = 0xFFFF;
for ( i = 0; i < tmp =" (unsigned" j =" 0;" lsb =" crc">>= 1;
if ( lsb != 0 ) crc ^= 0xA001;
}
}
return (crc);
}
Figure illustrates how to connect the UART interface of the FT232BL to a TTL – RS232 Level Converter I.C. to make a USB to RS232 converter using the popular “213” series of TTL to RS232 level converters. These devices have 4 transmitters and 5 receivers in a 28 LD SSOP package and feature an in-built voltage converter to convert the 5v (nominal) VCC to the +/- 9 volts required by RS232. An important feature of these devices is the SHDN# pin which can power down the device to a low quiescent current during USB suspend modeThe device used in the example is a Sipex SP213EHCA which is capable of RS232 communication at up to 500K baud. If a lower baud rate is acceptable, then several pin compatible alternatives are available such as Sipex SP213ECA , Maxim MAX213CAI and Analog Devices ADM213E which are good for communication at up to 115,200 baud. If a higher baud rate is desired, use a Maxim MAX3245CAI part which is capable of RS232 communication at rates of up to 1M baud. The MAX3245 is not pin compatible with the 213 series devices, also its SHDN pin is active high so connect this to PWREN# instead of SLEEP#.
http://www.ftdichip.com/Documents/DataSheets.htm