Datasheet
Copyright © 2013 ARM Ltd. All rights reserved
CAN: Controller Area Network Lab using ST STM32 Cortex-M processors. www.keil.com
7
Other Bit Fields: Only the ACK bit will be mentioned in this document:
ACK: This is a one bit field in the CAN frame created by the transmitting node but set by all the other nodes.
TIP: The number 1 reason people can’t get their CAN node working is you need at least two nodes to work. When a node
puts a message on the bus, it will wait for the ACK bit to be asserted by any other node that has seen the message and
determined it to be valid. If so, the transmitting node finishes the message and goes into the idle state or sends its next
message. If not, it will immediately resend the message forever until the ACK is asserted or the controller is RESET. This
transmitting node will never go into bus-off mode while re-transmitting this message. Note that a standard CAN test tool will
usually act as a second node by providing the ACK signal unless its controller has the ACK feature disabled.
TIP: This presents an excellent opportunity to provide an easy test situation to confirm you are sending out CAN frames. It
won’t tell you the frequency, ID or data bytes values, but it will tell you if you are putting out something.
1. Connect a termination resistor to your single CAN node with a transceiver connected to the CAN controller. If you
do not have a transceiver connected, join the TXD and RXD of the controller together. No resister is then needed.
2. Do not connect any other node or test tool. Just one node running by itself.
3. Connect an oscilloscope hot lead to CAN Hi and ground to CAN Lo. The scope ground must be isolated from the
CAN ground. You do not need a high speed scope – almost any will suffice. You can also connect a scope to the
CAN controller output pin and ground for a very clean signal.
4. Configure your CAN controller and write the IDE, ID, DLC and any data bytes into the appropriate registers.
5. A CAN frame will now be continuously displayed on the scope. RESET the processor to start over.
TIP: You can measure the CAN frequency with the method described at the bottom of this page.
Bit Stuffing:
The CAN protocol states that when there are 5 consecutive bits of the same polarity, one bit of opposite polarity will be
inserted to prevent sync loss. These bits make the CAN frame longer and are very common. These bits are inserted and
removed automatically by the CAN controller and are only visible when an oscilloscope is attached to the bus.
TIP: When bits are added (or not) to the CAN frame as various messages are sent on the bus, the changing frame length will
look like jitter on the bus. It is not jitter of course: CAN just works this way. Just something else to be aware of.
Bus Loading:
Many CAN networks work on a bus loading from 15 to 35 % and this is increasing in some applications. A higher bus
loading can cause lower priority messages to be delayed but these messages will still usually get through in a timely fashion.
It is quite difficult to achieve 100% bus loading but one can come close. System performance does not drop greatly at high
bus loading. Recall the message with the highest priority (lowest ID #) goes straight through with no time delay.
TIP: It is possible to get very high bus loads in a short period of time in a CAN network. CAN does not automatically space
out messages. It is possible to get a series of back-to-back messages that will equal nearly 100 % bus loading. You should
be prepared for this. One solution is to select only those messages needed by a node by programming its acceptance filter.
Another is to have your software space out the messages. This transitory problem is quite hard to detect and diagnose.
TIP: It is possible that on a highly loaded bus, low priority messages will never get transmitted or be delayed by higher ones.
Bus Speed:
Bus speed in a system is a balancing act between things such as propagation delays (from bus length) and EMI emissions
versus desired data throughput. Run your network as fast as possible for stable operation and with enough throughput. Do
not run it much faster than it needs to be, but make some room for later expansion. Choose standard bus speeds.
TIP: If your network is not stable: make sure you have two good termination resistors at each end of the network. Try
slowing the CAN speed down to see if this helps. Resistors can be 120 ohm ½ watt and their value is not critical. Try
adjusting the BTR0 and BTR1 timing registers to obtain the most stable operating parameters.
TIP: How to determine the bus frequency of a CAN signal: This is the best and sometimes only way to determine this.
1. Connect an oscilloscope to CAN Hi or CAN Lo and ground. You do not need a high speed scope – almost any will
suffice. You can also connect a scope to the CAN controller Tx output pin and ground for a very clean signal.
2. Display a trace. You might need a storage scope to see just one trace due to the non-repetitive nature of CAN.
3. Pick the smallest width signal pulse and measure its time period in seconds as accurately as you can.
4. Invert this value (divide into 1) and you have the CAN speed in bits per second. i.e. 2 µsec = 500 Kbps.