Professional Documents
Culture Documents
CAN
CAN
• Each CAN message can transmit from 0 to 8 bytes of user information. Of course, you
can transmit longer data information by using segmentation. The maximum
transmission rate is specified as 1 Mbit/s.
Mbit/s This value applies to networks up to 40 m.
For longer distances the data rate must be reduced. For distances up to 500 m a
speed of 125 kbit/s is possible, and for transmissions up to 1 km a data rate of 50
kbit/s is permitted.
• One important feature about the CAN node design is that the CAN
controller has separate transmit and receive paths. So, as the node
is writing on to the bus it is also listening back at the same time.
In “CAN speak” a logic one is called a recessive bit and a logic zero is
called a dominant bit. In all cases a dominant bit will overwrite a recessive
bit. So, if ten nodes write recessive and one writes dominant, then each
node will read back a dominant bit.
bit
The CAN bus has two message objects which may be generated by the
application software. The message object is used to transfer data around
the network. The message packet is shown below:
CAN arbitration:
Message arbitration guarantees that the most important message will win the
bus and be sent without any delay. Stalled messages will then be sent in order of
priority, lowest value identifier first.
• For the first two bits, all three messages write the same logic and hence read
back the same logic so each node continues transmission. However on the third
bit, node A and C write dominant bits and node B writes recessive. At this point,
node B wrote recessive but reads back dominant. In this case it will back off the
bus and start listening. Node A and C will continue transmission until node C
write recessive and node A writes dominant. Now node C stops transmission and
starts listening. Now node A has won the bus and will send its message. Once A
has finished, nodes B and C will transmit and node C will win and send its
message. Finally node B will send its message. If node A is scheduled again, it
will win the bus even though the node B and C messages have been waiting. In
practice the CAN bus will transmit the message with the lowest value identifier.
Ø SFRs Required:
Ø PINSEL1:
7:0 PRIO If the TPM bit in the CANMOD register is 1, enabled Tx Buffers
send their messages based on this field. The lowest binary value
highest is the priority.
priority
19:16 DLC This value is sent in the DLC field of the next transmit message. In
addition, if RTR=0,, this value controls the number of Data bytes
sent in the next transmit message, from the CANTDA and CANTDB
registers: 0000-0111
0111 = 0-7 bytes 1xxx = 8 bytes
30 RTR If this bit is 0, the number of data bytes called out by the DLC field
are sent from the CANTDA and CANTDB registers.
If it’s 1, a Remote Frame is sent, containing a request for that
number of bytes.
31 FF If this bit is 0, the next transmit message will be sent with an 11-bit
Identifier, while if it’s 1, the message will be sent with a 29-bit
Identifier.