Can CTRL Usg
Can CTRL Usg
Can CTRL Usg
The given application example is explained step by step in Figure 2-2. In this figure, LPF_x is the
abbreviation of “low priority frame” and HPF means “high priority frame”. As can be seen, LPF_1 is
blocked by other higher priority frames from other CAN nodes in the first part of the figure. The host
controller puts a fourth frame into the STB (LPF_4) and then decides to output the HPF. Meanwhile, the
CAN bus was free to transmit LPF_1 which is followed by HPF, LPF_2 and so on.
The priority decision between the PTB and STB is done by the CAN protocol machine, but the CAN
protocol itself uses another independent priority decision mechanism which is called bus arbitration. For
bus arbitration the frame identifier defines the priority level.
In the example given above, it would be possible to place a frame with a very low-priority identifier in the
PTB while higher priority frames remain in the STB. For the decision between PTB and STB always the
PTB wins regardless of the frame identifier. It is the task of the host controller to place frames with
meaningful identifier priorities in the appropriate buffers.
transmission request and abort the message. Aborting is possible for PTB and STB as well as for single
or all frame transmission.
The CAN FD specification by Bosch (non-ISO) uses the name EDL while the CAN FD ISO specification
uses the name FDF for the same bit. Both names are synonyms. This document uses the name EDL.
For CAN FD ISO frames the stuff count is transmitted as a part of the CRC field. For CAN FD non-ISO
frames the stuff count is not part of the frame. Furthermore the CRC checkers have a different
initialization for non-ISO and ISO frames. Therefore ISO and non-ISO frames are incompatible.
The CAN protocol machine in the CAN-CTRL core automatically transmits and receives the frames and
embeds the appropriate control and status bits. The host controller is required to select the desired frame
type (IDE, RTR, EDL), chose the identifier and set the data payload.
Setting both TSONE and TSALL is meaningless. While TSALL is already set, it is impossible to set
TSONE and vice versa. If both TSONE and TSALL are set simultaneously then TSALL wins and TSONE
is cleared by the CAN-CTRL core.
Table 3-10 Receive and Transmit Interrupt Enable Register RTIE (0xa4)
Table 3-11 Receive and Transmit Interrupt Flag Register RTIF (0xa5)
To reset an interrupt flag, the host controller needs to write an 1 to the flag. Writing a 0 has no effect. If a
new interrupt event occurs while the write access is active then this event will set the flag and override
the reset. This ensures that no interrupt event is lost.
Interrupt flags will only be set if the associated interrupt enable bit is set.
Table 3-12 ERRor INTerrupt Enable and Flag Register ERRINT (0xa6)
To reset an interrupt flag, the host controller needs to write an 1 to the flag. Writing a 0 has no effect. If a
new interrupt event occurs while the write access is active then this event will set the flag and override
the reset. This ensures that no interrupt event is lost.
Interrupt flags will only be set if the associated interrupt enable bit is set.
Writing to S_Seg_1, S_Seg_2, S_SJW, S_PRESC, F_Seg_1, F_Seg_2, F_SJW, F_PRESC and TDC is
only possible if RESET=1. A detailed description of the CAN bus bit timing is given in chap. 4. The reset
value sets the bit timing which is described in the example in chap. 6.3.
All timing parameters in are given for slow (prefix “S_”) and fast speed (prefix “F_”). Slow speed is used
for CAN 2.0 and the CAN FD arbitration phase. Fast speed is used for the CAN FD data phase.
Table 3-22 Error and Arbitration Lost Capture Register EALCAP (0xb0)
Reset
Bits Name Function
Value
Kind Of ERror (Error code)
000 - no error
001 - BIT ERROR
010 - FORM ERROR
011 - STUFF ERROR
100 - ACKNOWLEDGEMENT ERROR
7:5 KOER(2:0) r-0x0 101 - CRC ERROR
110 - OTHER ERROR
(dominant bits after own error flag, received active Error Flag too long,
dominant bit during Passive-Error-Flag after ACK error)
111 - not used
KOER is updated with each new error. Therefore it stays untouched when frames are
successfully transmitted or received.
4:0 ALC(4:0) r-0x0 Arbitration Lost Capture (bit position in the frame where the arbitration has been lost)
Table 3-23 Error Counter Registers RECNT (0xb2) and TECNT (0xb3)
Bits Name Access Function
Receive Error CouNT (number of errors during reception)
RECNT is incremented and decremented as defined in the CAN specification.
7:0 RECNT r-0x00
RECNT does not overflow. RECNT signals 0xff = 255 as maximum value. See chap. 3.6.7
for more details about RECNT and the “bus off” state.
Transmit Error CouNT (number of errors during transmission)
TECNT is incremented and decremented as defined in the CAN specification.
7:0 TECNT r-0x00
TECNT does not overflow. TECNT signals 0xff = 255 as maximum value. See chap. 3.6.7
for more details about TECNT and the “bus off” state.
The acceptance filter registers ACF_x provide access to the acceptance filter codes ACODE_x and
acceptance filter masks AMASK_x depending on the setting of SELMASK. (See Figure 3-4 and also
Table 3-4). Read / Write access to ACF_x is only possible if RESET=1. If RESET=0 then reading from
ACF_x results in the value 0.
The acceptance filters are build using a true 32 bit wide memory and therefore a write access needs to
be performed as 32 bit write. See chap. 7.1.3 for further details.
The AMASK_x includes additional bits in register ACF_3 (Table 3-27) which can be only accessed if
SELMASK=1. These bits can be used to accept only either standard or extended frames with the
selected ACODE / AMASK setting or to accept both frame types. Only acceptance filter 0 is affected by
the power-on reset and it is configured to accept both frame types after power-up.
To reset an interrupt flag, the host controller needs to write an 1 to the flag. Writing a 0 has no effect. If a
new interrupt event occurs while the write access is active then this event will set the flag and override
the reset. This ensures that no interrupt event is lost.
Interrupt flags will only be set if the associated interrupt enable bit is set.
Table 3-4 gives a definition of the bit positions of REF_ID and REF_IDE inside REF_MSG_0 to
REF_MSG_2.
A write access to REF_MSG_3 starts a data transfer of the reference message to the CAN clock domain
(clock domain crossing). During this automatic transfer a write lock for all registers REF_MSG_0 to
REF_MSG_2 is active. The transfer takes up to 6 clocks in the CAN clock domain and up to 6 clocks in
the host clock domain. The write access to REF_MSG_2 is necessary to make a new reference
message active.
Table 3-37 TTCAN: Trigger Time TT_TRIG_0 and TT_TRIG_1 (0xc6 and 0xc7)
Bits Name Access Function
Trigger Time
7:0 TT_TRIG rw-0x00 TT_TRIG(15:0) defines the cycle time for a trigger. For a transmission trigger the
earliest point of transmission of the SOF of the appropriate frame will be TT_TRIG+1.
A write access to TT_TRIG_1 starts a data transfer of the trigger definition to the CAN clock domain
(clock domain crossing) and activates the trigger. If the trigger is active, then a write lock for all registers
TRIG_CFG_0, TRIG_CFG_1, TT_TRIG_0 and TT_TRIG_1 is active. The write lock becomes inactive
when the trigger time is reached (TTIF gets set is TTIE is enabled) or an error is detected (TEIF gets
set).
Table 3-38 TTCAN: Watch Trigger Time TT_WTRIG_0 and TT_WTRIG_1 (0xc8 and 0xc9)
Bits Name Access Function
Watch Trigger Time
7:0 TT_WTRIG rw-0xff TT_WTRIG(15:0) defines the cycle time for a watch trigger. The initial watch trigger is
the maximum cycle time 0xffff. See chap. 4.5 for more details.
A write access to TT_WTRIG_1 starts a data transfer of the trigger definition to the CAN clock domain
(clock domain crossing). During this automatic transfer a write lock for the registers TT_WTRIG_0 and
TT_WTRIG_1 is active. The transfer takes up to 6 clocks in the CAN clock domain and up to 6 clocks in
the host clock domain. The write access to TT_WTRIG_1 is necessary to make a new trigger active.
The RBUF registers (0x00 to 0x47) point the message slot with the oldest received message in the RB
as can be seen in Figure 3-5. All RBUF registers can be read in any order.
KOER in RBUF has the same meaning as the bits KOER in register EALCAP. KOER in RBUF becomes
meaningful if RBALL=1 (chap. 3.6.9.4).
Status bit TX in RBUF is set to 1 if the loop back mode (chap. 3.6.10.4) is activated and the core has
received its own transmitted frame. This can be useful if LBME=1 and other nodes in the network do also
transmissions.
The time-stamp CYCLE_TIME will be stored in RBUF only in TTCAN mode. This is the cycle time at the
SOF of this frame. The cycle time of a reference message is always 0.
The Reception Time Stamps (RTS) for CiA 603 time-stamping are stored for each received message at
the end of the RBUF address range. Therefore in contrast to TTS, RTS is related to the actual selected
RBUF slot.
The TBUF registers (0x48 to 0x8f) point the next empty message slot in the STB if TBSEL=1 or to the
PTB otherwise. Seen in Figure 3-6 for more details. All TBUF registers can be written in any order. For
the STB it is necessary to set TSNEXT to mark a slot filled and to jump to the next message slot.
Please mind the gap inside the addressing range of TBUF from TBUF+5 to TBUF+7. This is for better
address segment alignment. The memory cells in the gap can be read and written, but have no meaning
for the CAN protocol.
TBUF is build using a true 32 bit wide memory and therefore a write access needs to be performed as 32
bit write. See chap. 7.1.3 for further details.
Both RBUF and TBUF include some frame-individual control bits (Table 3-43). For RBUF these bits
signal the status of the appropriate CAN control field bits of the received CAN frame while for TBUF
these bits select the appropriate CAN control field bit for the frame that has to be transmitted.
In contrast to RTS, which is stored for every received frame, TTS is stored only for the last transmitted
frame if TTSEN=1. TTS is not related to the actual selected TBUF slot.
The Data Length Code (DLC) in RBUF and TBUF defines the length of the payload – the number of
payload bytes in a frame. See Table 3-44 for further details.
Remote frames (only for CAN 2.0 frames where EDL=0) are always transmitted with 0 payload bytes, but
the content of the DLC is transmitted in the frame header. Therefore it is possible to code some
information into the DLC bits for remote frames. But then care needs to be taken if different CAN nodes
are allowed to transmit a remote frame with the same ID. In this case all transmitters need to use the
same DLC because otherwise this would result in an unresolvable collision.
Table 3-44 Definition of the DLC (according to the CAN 2.0 / FD specification)
DLC (binary) Frame Type Payload in Bytes
0000 to 1000 CAN 2.0 and CAN FD 0 to 8
1001 to 1111 CAN 2.0 8
1001 CAN FD 12
1010 CAN FD 16
1011 CAN FD 20
1100 CAN FD 24
1101 CAN FD 32
1110 CAN FD 48
1111 CAN FD 64
Figure 3-6 Schematic of PTB and STB in FIFO mode (empty PTB and 6 STB slots)
The TBUF registers and readable and writable. Therefore a host controller may use TBUF to
successively prepare a message bit-by-bit if necessary.
The acceptance mask defines which bits shall be compared while the acceptance code defines the
appropriate values. Setting mask bits to 0 enables the comparison of the selected acceptance code bits
with the corresponding message identifier bits. Mask bits that are set to 1 are disabled for the
acceptance check and this results in accepting the message.
The identifier bits will be compared with the corresponding acceptance code bits ACODE as follows:
standard: ID(10:0) with ACODE(10:0)
extended: ID(28:0) with ACODE(28:0)
Example: If AMASK_x(0)=0 and all other AMASK_x bits are 1 then the value of the last ID bit has to be
equal to ACODE(0) for an accepted message. All other ID bits are ignored by the filter.
Figure 3-7 gives an example of acceptance filtering using several filters. In this example the filter 0 and 1
are enabled by the appropriate AE_x bits in the ACF_EN_x registers. All other filters are disabled and
therefore do not accept any message. For the enabled filters the combination of AMASX_x and
ACODE_x defines if a message is accepted (like in the example for filter 0) or not accepted (like in the
example for filter 1).
Note: Disabling a filter by setting AE_x=0 blocks messages. In contrast to this disabling a mask bit in
AMASK_x disables the check for this bit which results in accepting messages.
The definitions of AMASK and ACODE alone do not distinguish between standard or extended frames. If
bit AIDEE=1 then the value of AIDE defines with frame type is accepted. Otherwise if AIDE=0 both types
are accepted.
After power-on reset the CAN-CTRL core is configured to accept all messages. (Filter 0 is enabled by
AE_0=1, all bits in AMASK_0 are set to 1 and AIDEE=0. All other filters are disabled. Filter 0 is the only
filter that has defined reset values for AMASK / ACODE while all other filters have undefined reset
values.)
The RB always maps the message slot containing the oldest message to the RBUF registers.
The maximum payload length for CAN 2.0 messages is 8 bytes and for CAN FD messages 64 bytes.
The individual length of each message is defined by the DLC. Because of this the RB provides slots for
each message and the host controller is required to set RREL to jump to the next RB slot. All RBUF
bytes of the actual slot can be read in any order.
th
If the RB is full, the next incoming message will be stored temporarily until it passes for valid (6 EOF
bit). Then if ROM=0 the oldest message will be overwritten by the newest or if ROM=1 the newest
message will be discarded. In both cases ROIF is set if ROIE is enabled. If the host controller reads the
oldest message and sets RREL before a new incoming message becomes valid then no message will be
lost.
Figure 3-9 Schematic of PTB and STB in FIFO mode (empty PTB and 6 STB slots)
The maximum payload length for CAN 2.0 messages is 8 bytes and for CAN FD messages 64 bytes.
The individual length of each message is defined by the DLC. For remote frames (bit RTR) the DLC
becomes meaningless, because remote frames always have a data length of 0 bytes. The host controller
is required to set TSNEXT to jump to the next STB slot. All TBUF bytes can be written in any order.
Setting TSNEXT=1 is meaningless if TBSEL=0 selects the PTB. In this case TSNEXT is automatically
cleared and does no harm.
Bit TPE should be set to start a transmission when using the PTB. To use the STB, TSONE has to be set
to start a transmission of a single message or TSALL to transmit all messages.
The PTB has always a higher priority than the STB. If both transmit buffers have the order to transmit,
the PTB message will be always sent first regardless of the frame identifiers. If a transmission from the
STB is already active, it will be completed before the message from the PTB is sent at the next possible
transmit position (the next interframe slot). After the PTB transmission is completed or aborted, the CAN-
CTRL core returns to process other pending messages from the STB. See also chap. 2.3.3 for further
details.
When the transmission is completed, the following transmission interrupts are set:
For the PTB, TPIF is set if TPIE is enabled
For the STB using TSONE, TSIF is set if one message has been completed and TSIE is
enabled.
For the STB using TSALL, TSIF is set if all messages have been completed and if TSIE is
enabled. In other words: TSIE is set if the STB is empty. Therefore, if the host controller writes
an additional message to the STB after a TSALL transmission has been started then the
additional message will be also transmitted before TSIF will be set.
It is meaningless to set TSONE or TSALL while the STB is empty. In such a case TSONE respectively
TSALL will be reset automatically. No interrupt flag will be set and no frame will be transmitted.
3. Bus Off: After too many errors a node goes “bus off” where it stops touching the bus.
To handle the 3 error states every CAN node has two error counters: the transmit and the receive error
counter. Both are incremented and decremented as defined by the CAN specification and the node
enters the appropriate error state upon reaching a counter level defined by the CAN specification.
The error counters are incremented if there are errors. Dangerous errors that are probably caused by
this node will result in incrementing the counter by 8, errors that are probably caused by other nodes will
result in incrementing the counter by 1. Valid frame transmission or valid receptions result in
decrementing the counters. All this is defined by the CAN specification and handled automatically by
CAN-CTRL.
An error frame (better: an error flag) is different to a data frame. It is a dominant pulse for at least 6
consecutive dominant bits, which is a stuff bit violation for other nodes. A host controller cannot
command to transmit an error frame. It is done fully automatically by CAN-CTRL.
If CAN-CTRL is commanded to transmit a frame then it automatically tries retransmissions as fast as
possible until the frame gets transmitted without error or the node goes bus off. If a frame is received and
CAN-CTRL detects an error, then the received data is discarded. Because of the automatically
transmitted error frame the sender of the frame will retransmit the frame. Frames in RBUF are never
overwritten by frames with errors. Only valid received frames may result in a RBUF overflow.
Arbitration is only allowed in the arbitration field (Figure 2-3). Therefore the maximum value of ALC is 31
which is the RTR bit in extended frames.
Additional hint: If a standard remote frame arbitrates with an extended frame, then the extended frame
loses arbitration at the IDE bit and ALC will be 12. The node transmitting the standard remote frame will
not notice that an arbitration has been taken place, because this node has won.
It is impossible to get an arbitration loss outside of the arbitration field. Such an event is a bit error.
3.6.9.3. Kind Of Error (KOER)
The core recognizes errors on the CAN bus and stores the last error event in the KOER bits. A CAN bus
error can be signaled by the BEIF interrupt if it is enabled. Every new error event overwrites the previous
stored value of KOER. Therefore the host controller has to react quickly on the error event. The error
codes are described in the table 3-15.
KOER is updated with each new error. Therefore it stays untouched when frames are successfully
transmitted or received. This opens the opportunity for a delayed error investigation.
3.6.9.4. Reception of All Data Frames (RBALL)
If RBALL=1 then all received data frames are stored even those with error. This holds also for loop back
mode (chap. 3.6.10.4). Only data frames are stored in RBUF. Error frames or overload frames are not
stored.
If CiA 603 time-stamping (chap. 5) is enabled (TIMEEN=1) and the timestamp is configured for the EOF
(TIMEPOS=1) then in the case of an error the time-stamp is acquired at the start of the error frame.
Most of the possible errors can only occur if the node is the transmitter of the frame. In this case a frame
would only be stored in RBUF if a loop back mode is activated. Depending on the type of error parts of
the frame stored in an RBUF slot may be valid while other parts are unknown. Table 3-45 lists the
possibilities.
Table 3-45 RBALL and KOER
KOER Condition Description
no error All Successful reception.
Receiver Can only occur in the ACK slot. All stored data are valid.
The payload is always invalid. The header bits including the ID may be valid. In
the arbitration phase detection of a wrong bit is part of the arbitration and
BIT ERROR therefore not a BIT ERROR. But if a stuff bit in the arbitration phase is detected
Transmitter wrong by the transmitter of the frame, then this is a BIT ERROR and in this case
the header bits are invalid. Therefore the header bits cannot be trusted, but if the
header matches to an expected header of a frame, it can be used for further
investigation.
Only FORM ERRORs in a data frame are covered. This includes errors in the CRC
FORM ERROR All
delimiter, the ACK delimiter or the EOF bits. All stored data are valid.
Receiver The position of a STUFF ERROR is unknown. All stored data are invalid.
STUFF ERROR
Transmitter Can only happen during arbitration. All stored data are invalid.
Receiver Can only occur if the node is in LOM. All stored data are valid.
ACK ERROR
Transmitter Can only occur in loop back mode without self-ACK. All stored data are valid.
CRC ERROR Receiver All stored data are invalid.
Please note that even if Table 3-45 states that (parts of) the data are valid under certain conditions, then
care must be taken. There is no guarantee for this and it depends on the reason for the error if this
statement is correct. Example: if the node has a bad bit timing configuration then there is no correct
synchronization and therefore no valid data. Therefore the statement that (parts of) the data is valid
signals only the possibility that it is so.
ACK to frames from other nodes and will not generate error or overload frames. In Summary the
combination of LOM and LBME is “a silent receiver, that is able to transmit if necessary”.
3.6.10.3. Bus Connection Test
To check if a node is connected to the bus the following steps shall be done:
Transmit a frame. If the node is connected to the bus then its TX bits are visible on its RX input.
If there are other nodes connected to the CAN bus, then a successful transmission (including an
acknowledge from the other nodes) is expected. No error will be signaled.
If the node is the only node that is connected to the CAN bus (but the connection between the
bus, the transceiver and the CAN-CTRL core is fine) then the first regular error situation occurs
in the ACK slot because of no acknowledge from other nodes. Then a BEIF error interrupt will be
generated if enabled and KOER=“100” (ACK error).
If the connection to the transceiver or the bus is broken then immediately after the SOF bit the
BEIF error interrupt will be set and KOER=“001” (BIT error).
3.6.10.4. Loop Back Mode (LBMI and LBME)
CAN-CTRL supports two Loop Back Modes: internal (LBMI) and external (LBME). Both modes result in
reception of the own transmitted frame which can be useful for self-tests. See Figure 3-10 for details.
In LBMI CAN-CTRL is disconnected from the CAN bus and the txd output is set to recessive. The output
data stream is internally fed back to the input. In LBMI the node generates a self-ACK to avoid an ACK
error.
In LBME CAN-CTRL stays connected to the transceiver and a transmitted frame will be visible on the
bus. With the help of the transceiver CAN-CTRL receives its own frame. In LBME the node does not
generate a self-ACK when SACK=0, but generates a self-ACK when SACK=1. Therefore in LBME with
SACK=0 there are two possible results upon a frame transmission:
1. Another node receives the frame too and generates an ACK. This will result in a successful
transmission and reception.
2. No other node is connected to the bus and this results in an ACK error. To avoid retransmissions
and incrementing the error counters it is recommended to use TPSS or TSSS if it is unknown if
other nodes are connected.
In Loop Back Mode the core receives its own message, stores it in the RBUF and sets the appropriate
receive and transmit interrupt flags if enabled.
LBMI can be useful for chip-internal and software tests while LBME can test the transceiver and the
connections to it.
Activation of LBMI or LBME should not be done while a transmission is active. The host controller has to
take care of this. There is not additional protection from CAN-CTRL.
If the node is connected to a CAN bus then switching back from LBMI to normal operation must not be
done by simply setting LBMI to 0, because then it may be that this occurs just at the moment while
another CAN node is transmitting. In this case switching back to normal operation shall be done by
setting bit RESET to 1. This automatically clears LBMI to 0. Finally RESET can be disabled and the core
returns back to normal operation. In contrast to this LBME can be disabled every time.
LBME can be used in combination with LOM. Details are given in chap. 3.6.10.2.
3.6.10.5. Transceiver Standby Mode
Using the register bit STBY the output signal stby is driven. It can be used to activate a standby mode for
a transceiver. The behavior is compatible to the NXP TJA1049 transceiver.
Once standby is activated no transmission is possible and therefore TPE, TSONE and TSALL cannot be
set. On the other hand CAN-CTRL does not allow STBY to be set if a transmission is already active
(TPE, TSONE or TSALL is set).
If STBY is set the transceiver enters a low-power mode. In this mode it is unable to receive a frame at full
speed but monitors the CAN bus for a dominant state. If the dominant state is active for a time which is
defined in the transceivers data sheet the transceiver will pull the rxd signal low. If rxd is low CAN-CTRL
automatically clears STBY to 0 which disables standby mode for the transceiver. This is done silently
without an interrupt to the host controller.
Switching from standby mode to active mode takes some time for the transceiver and therefore the initial
wakeup frame cannot be received successfully. Therefore the node recently being in standby will not
respond with an ACK. If no CAN node at the bus responds to the wakeup frame with an ACK then this
results in an ACK error for the transmitter of the wakeup frame. Then the transmitter will automatically
repeat the frame. During the repetition the transceiver will be back in active mode and CAN-CTRL will
receive the frame and will respond with an ACK.
In summary: One node transmits a frame for wakeup. If all others nodes are in standby mode, then the
transmitter gets an ACK error and will automatically repeat the frame. During the repetition the nodes are
back in active mode and will respond with an ACK.
STBY is not affected by bit RESET.
3.6.10.6. Error Counter Reset
According to the CAN / CAN FD standard RECNT counts receive errors and TECNT counts transmit
errors. After too many transmit errors a CAN node has to go to busoff state (chap. 3.6.7 ). This will
activate the bit RESET. Deactivating the bit RESET does not modify the errors counters or busoff state.
The CAN / CAN FD specification defines rules how to disable busoff state and to decrease the error
counters. A good node will recover from all of this automatically if only a temporary error has caused the
problems. The classic CAN 2.0B specification requires this automatic behavior without host controller
interaction to avoid the babbling idiot problem.
The CAN FD specification relaxes this and allows the host controller to override the automatic error
counter handling. But this should be used with extra care and is suggested to use only for debugging
purposes.
Writing a 1 to the bit BUSOFF resets the error counters and therefore forces the node to leave the busoff
state. This is done without setting EIF.
6.2 Definitions
The CAN bit time BT consists of several segments as shown in Figure 6-1. Each segment consists of a
number of time quanta units nTQ . The duration of a time quanta TQ is:
n prescaler
TQ
f CLOCK
The values of nTQ and n prescaler have to be chosen depending on the system clock frequency f CLOCK to
match BTreal as close as possible to BTideal 1 BR where BR is the CAN bus baud rate:
n prescaler nTQ
BTideal BTreal t Seg_1 t Segt_2
f CLOCK
The CAN specification requires several relationships between the segment lengths (Table 6-1) which
results in relationships between t Seg _ 1 , t Seg _ 2 and the maximum synchronization jump width t SJW . Please
note that Table 6-1 lists the minimum configuration ranges defined by the CAN / CAN FD specification.
For CAN 2.0 bit rate and CAN FD (slow) nominal bit rate the register settings S_Seg_1, S_Seg_2,
S_SJW and S_PRESC define the appropriate segment lengths. For CAN FD (fast) data bit rate the
register F_Seg_1, F_Seg_2, F_SJW and F_PRESC are valid.
t Seg _ 1 S _ Seg _ 1 2 TQ t Seg _ 1 F _ Seg _ 1 2 TQ
t Seg _ 2 S _ Seg _ 2 1 TQ t Seg _ 2 F _ Seg _ 2 1 TQ
t SJW S _ SJW 1 TQ t SJW F _ SJW 1 TQ
n prescaler S _ PRESC 1 n prescaler F _ PRESC 1
A CAN FD core switches from slow nominal bit rate to fast data bit rate at the sample point in the BRS bit
and switches back at the sample point in the CRC delimiter bit.
f CLOCK
An illustration a suitable bit rate configuration is given in Figure 6-2 where f tq_clk . The bit time
n prescaler
BTreal , the sample point and the synchronization jump width SJW will be derived from tq_clk.
Having the requirements from Table 6-2 in mind the host controller has to define the length of segment 1,
segment 2 and the synchronization jump width for the slow bit rate and if required for CAN FD for the fast
bit rate.
Some suggestions, given as rules of the thumb:
Segment 1 must be slightly larger than segment 2. Then the sample point is in the a little bit later
than in the middle of the bit time.
The synchronization jump width must not be bigger than segment 2. If SJW is too small the CAN
node may be too slow to resynchronize, if SJW is too big then the CAN node may resynchronize
too often. SJW being half as long as segment 2 seems to be a suitable value.
All CAN nodes connected to a CAN bus should choose similar settings if possible.
The fastest CAN bus speed can be configured using the minimum timing values. But there are some
things that need to be considered:
If the prescalers are bigger than one then all other timing parameters could be set to zero, but
this violates the rule t Seg _ 1 t Seg _ 2 2 (slow speed) resp. t Seg _ 1 t Seg _ 2 1 (fast speed) and
therefore S_Seg_1 and F_Seg_1 should be at least set to 1. But such a selecting of timing
parameters works in theory, but may not be robust enough for real nets.
If the prescalers are set to one then synchronization becomes difficult. In general the CAN
specification requires one bit time to be at least 8 TQ long for CAN 2.0 and CAN FD slow
nominal bit rate. For CAN-CTRL one bit time of fast data bit rate needs to be also at least 8 TQ
long if the fast prescaler is set to 1.
In summary the fastest CAN bus frequency is the can_clk frequency divided by 8: prescalers set
to 1 and 8 TQ bit time.
and t Seg_2 3 TQ can be chosen as suitable values which finally results in the register settings
S_Seg_1=3 and S_Seg_2=2.
3. Load the acceptance code and mask registers (optional).
4. Set register S_SJW:
With t Seg_2 t SJW one is free to chose t SJW 3 which finally results in 2.
5. Load the clock prescaler register S_PRESC: n prescaler PRESC 1 results in S_PRESC=1.
6. Set bit RESET=0.
The given order is not mandatory. It is merely necessary to set bit RESET=1 at the beginning, as
it is otherwise not possible to load the bit timing, ACODE and AMASK registers. RESET=0 is
required upon completion of the configuration. The controller then waits for 8 recessive bits
(frame end) and resumes its normal operation.
7. Continue with configuration of interrupts other configuration bits and execute commands.
Figure 6-4 gives an example of the effect of a big transmitter delay. In this figure a txd data stream is
shown starting with bits A and B. One bit time consists of t Seg_1 5 TQ before the Sample Point (SP)
and t Seg_2 3 TQ behind. In this example the transmitter delay is longer than 2 bit times. Therefore the
original SP cannot be used to sample the correct bit value and the CAN FD specification defines an
additional Secondary Sample Point (SSP). If TDC is enabled with bit TDCEN=1 then CAN-CTRL
automatically determines the transmitter delay. The position of the SSP is the transmitter delay plus the
SSP Offset which is defined by the configuration bits SSPOFF. SSPOFF must be given as a number of
TQ and it is suggested to set t Seg_1 equal to SSPOFF. (Please remember that F_SEG_1 defines t Seg_1
during data bit rate. Therefore in the example given in Figure 6-4 SSPOFF=5 is chosen.)
CAN-CTRL is capable of automatically determining a transmitter delay of at least 4 bit times of the fast
data bit rate. The exact amount depends on the system clock and the chosen CAN bit timing
configuration.
A delay bigger than a bit time needs to be taken into account also for receiving nodes. CAN FD defines
an additional hard synchronization at the falling edge between bit EDL=1 and the following r0 bit. (At this
time the slow nominal bit rate is active.) Synchronization for CAN and CAN FD is in general defined to
operate in time steps of one TQ. But steps of one TQ at nominal bit rate may be to coarse for a
synchronization for the fast data bit rate. Therefore the additional hard synchronization at the EDL bit
needs to violate this rule and needs to synchronize as exact as possible and only limited by the clock
frequency of the system. CAN-CTRL uses this special synchronization and this is called RDC. RDC is
automatically done during reception if EDL=1, no matter if TDC is enabled or not.
Abbreviation Description
PSP Primary Sample Point
SSP Secondary Sample Point
Seg 1 Segment 1
Seg 2 Segment 2
TDC Transmitter Delay Compensation (see SSPOFF)