Fraunf Can-Ctrl-Usg 2015
Fraunf Can-Ctrl-Usg 2015
Users Guide
October 2015
IP Product Version
5H(V)97N00S00
Document Signature
CAN-CTRL–USG–5H(V)97N00S00–131
CAST, Inc.
CONFIDENTIAL
CAN-CTRL Core Users Guide
Document Version
This document with its associated Release Notes applies to the version(s) of the core specified on the
cover. See the Release Notes for any updates and additional information not included here.
Table 1-1 Document Version History
Table of Contents
1. Introduction ............................................................................................................................ 8
1.1 The CAN-CTRL Core ...................................................................................................... 8
1.2 The CAN Protocol ........................................................................................................... 8
1.3 Using the CAN-CTRL Core ............................................................................................. 9
2. Features ................................................................................................................................ 10
2.1 Feature List ................................................................................................................... 10
2.2 Upward Compatibility .....................................................................................................11
2.3 Message Buffers ............................................................................................................11
2.3.1 Message Buffers Concept .....................................................................................11
2.3.2 Receive Buffer.......................................................................................................11
2.3.3 Transmit Buffer ..................................................................................................... 12
2.3.4 Transmit Buffer Application Example ................................................................... 12
2.3.5 Aborting a Transmission ....................................................................................... 13
2.4 CAN 2.0 and CAN FD Frames ...................................................................................... 13
3. Interfaces .............................................................................................................................. 15
3.1 Hardware Interface........................................................................................................ 15
3.2 Configuration Parameters ............................................................................................. 16
3.3 Definitions ..................................................................................................................... 16
3.4 Clock Domain Crossing ................................................................................................ 17
3.5 Software Interface ......................................................................................................... 17
3.6 General Operation......................................................................................................... 33
3.6.1 The Bus Off State ................................................................................................. 33
3.6.2 Acceptance Filters ................................................................................................ 33
3.6.3 Message Reception ............................................................................................. 34
3.6.4 Handling message receptions .............................................................................. 35
3.6.5 Message Transmission ........................................................................................ 35
3.6.6 Message transmission abort ................................................................................ 36
3.6.7 A Full STB ............................................................................................................ 37
3.6.8 Extended Status and Error Report ....................................................................... 37
3.6.8.1. Programmable Error Warning Limit ...................................................... 37
3.6.8.2. Arbitration Lost Capture (ALC) ............................................................. 38
3.6.8.3. Kind Of Error (KOER) ........................................................................... 38
3.6.9 Extended Features ............................................................................................... 38
3.6.9.1. Single Shot Transmission ..................................................................... 38
3.6.9.2. Listen Only Mode (LOM) ...................................................................... 38
3.6.9.3. Bus Connection Test ............................................................................. 39
3.6.9.4. Loop Back Mode (LBMI and LBME) ..................................................... 39
3.6.9.5. Transceiver Standby Mode ................................................................... 40
3.6.10 Software Reset................................................................................................... 40
4. CAN Bit Time ........................................................................................................................ 42
4.1 Data Bit Rates ............................................................................................................... 42
4.2 Definitions ..................................................................................................................... 42
4.3 Example Configuration .................................................................................................. 44
4.4 CAN Bit timing Calculator (CBC) .................................................................................. 45
4.5 Bit Rate Switching and the Sample Point ..................................................................... 45
4.6 Bit Timing Configuration for CAN FD Nodes ................................................................. 46
4.7 TDC and RDC ............................................................................................................... 46
4.8 Bit Timing Recommendations ....................................................................................... 47
5. Host Interfaces ..................................................................................................................... 49
5.1 Generic 32 Bit Wide Synchronous Host Interface ........................................................ 49
5.1.1 Register Write ...................................................................................................... 49
5.1.2 Register Read ...................................................................................................... 49
5.1.3 Data Alignment ..................................................................................................... 50
5.2 Generic 8 Bit Wide Synchronous Host Interface .......................................................... 50
List of Figures
Figure 1-1 Connection to CAN Bus and Main Features of the CAN-CTRL Core.......................... 8
Figure 2-1 Message Buffers Concept ...........................................................................................11
Figure 2-2 Transmit Buffer Application Example (TSALL=1) ...................................................... 13
Figure 2-3 CAN 2.0 and CAN FD Frame Types .......................................................................... 14
Figure 3-1 CAN-CTRL Core Pinout ............................................................................................. 15
Figure 3-2 Clock Domain Crossing ............................................................................................. 17
Figure 3-3 Memory Map for 8 / 16 / 32 Bit Interface ................................................................... 20
Figure 3-4 Access to the Acceptance Filters ............................................................................... 28
Figure 3-5 Schematic of the FIFO-like RB (example with 6 slots) .............................................. 30
Figure 3-6 Schematic of PTB and FIFO-like STB (empty PTB and 6 STB slots) ....................... 33
Figure 3-7 Example of acceptance filtering ................................................................................. 34
Figure 3-8 Schematic of the FIFO-like RB (example with 6 slots) .............................................. 35
Figure 3-9 Schematic of PTB and FIFO-like STB (empty PTB and 6 STB slots) ....................... 36
Figure 3-10 Loop Back Mode: Internal and External ................................................................... 39
Figure 4-1 CAN Bit Timing Specifications ................................................................................... 42
Figure 4-2 Clock Division for Bit Sampling .................................................................................. 44
Figure 4-3 Bit Rate Switching at bit BRS S _ PRESC F _ PRESC ................................... 46
Figure 4-4 Transmitter Delay ....................................................................................................... 46
Figure 5-1 Write Operation .......................................................................................................... 49
Figure 5-2 Read Operation .......................................................................................................... 49
Figure 5-3 Generic 8 Bit Wide Host Interface (only relevant signals shown) .............................. 50
Figure 5-4 Write Operation with 8 Bit Host Interface ................................................................... 51
Figure 5-5 AMBA APB Wrapper (only relevant bits shown) ........................................................ 51
Figure 5-6 AMBA AHB Wrapper (only relevant bits shown) ........................................................ 52
Figure 6-1 Block Diagram ............................................................................................................ 53
Figure 7-1 CAN Multicore – Connection Options to the CAN Bus .............................................. 55
Figure 8-1 Concept of /tb/tbench.v(hd) ....................................................................................... 57
Figure 8-2 Testbench for the CAN Multicore ............................................................................... 57
List of Tables
Table 1-1 Document Version History ............................................................................................. 2
Table 2-1 CAN Bit Abbreviations ................................................................................................. 14
Table 3-1 Pin Description ............................................................................................................ 15
Table 3-2 Parameter Description ................................................................................................. 16
Table 3-3 Name Definitions ......................................................................................................... 16
Table 3-4 Register Map ............................................................................................................... 18
Table 3-5 Configuration and Status Register CFG_STAT ........................................................... 21
Table 3-6 Command Register TCMD .......................................................................................... 21
Table 3-7 Transmit Control Register TCTRL ............................................................................... 23
Table 3-8 Receive Control Register RCTRL ............................................................................... 23
Table 3-9 Receive and Transmit Interrupt Enable Register RTIE ............................................... 24
Table 3-10 Receive and Transmit Interrupt Flag Register RTIF .................................................. 24
Table 3-11 ERRor INTerrupt Enable and Flag Register ERRINT ................................................ 25
Table 3-12 Bit Timing Register BITTIME_0 ................................................................................. 25
Table 3-13 Bit Timing Register BITTIME_1 ................................................................................. 25
Table 3-14 Bit Timing Register BITTIME_2 ................................................................................. 26
Table 3-15 Bit Timing Register BITTIME_3 ................................................................................. 26
Table 3-16 Prescaler Registers S_PRESC and F_PRESC ........................................................ 26
Table 3-17 Transmitter Delay Compensation Register TDC ....................................................... 26
Table 3-18 Warning Limits Register LIMIT .................................................................................. 27
Table 3-19 Error and Arbitration Lost Capture Register EALCAP ............................................... 27
Table 3-20 Error Counter Registers RECNT and TECNT ........................................................... 27
Table 3-21 Acceptance Filter Control Register ACFCTRL .......................................................... 28
Table 3-22 Acceptance CODE ACODE_x ................................................................................... 28
Table 3-23 Acceptance MASK AMASK_x.................................................................................... 29
Table 3-24 Bits in Register ACF_3, if SELMASK=1 .................................................................... 29
Table 3-25 Acceptance Filter Enable ACF_EN_0 ........................................................................ 29
Table 3-26 Acceptance Filter Enable ACF_EN_1 ........................................................................ 29
Table 3-27 Version Information VER_1 and VER_0 .................................................................... 29
Table 3-28 Receive Buffer Registers RBUF – Standard Format (r-0) ......................................... 30
Table 3-29 Receive Buffer Registers RBUF – Extended Format (r-0) ........................................ 30
Table 3-30 Transmit Buffer Registers TBUF – Standard Format (rw-u) ...................................... 31
Table 3-31 Transmit Buffer Registers TBUF – Extended Format (rw-u) ..................................... 31
Table 3-32 Control bits in RBUF and TBUF ................................................................................ 32
Table 3-33 Definition of the DLC (according to the CAN 2.0 / FD specification) ......................... 32
Table 3-34 Software Reset .......................................................................................................... 40
Table 4-1 CAN Timing Segments (Minimum Configuration Ranges) .......................................... 43
1. Introduction
Figure 1-1 Connection to CAN Bus and Main Features of the CAN-CTRL Core
2. Features
message, when the RB is full or filled to a user-selectable “almost full” limit. Because of the FIFO-like
behavior, the host controller always reads the oldest message from the RB.
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.
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. 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.
3. Interfaces
The master resets can_rst_b and host_rst_b are asynchronous resets. It is recommended to use reset
synchronizers for these signals for protection against recovery and removal timing issues. This core does
not include such reset synchronizers. They should be added outside of the core.
CAN-CTRL includes two clock domains: one for the host interface and one for the CAN protocol
machine. All signals between the two clock domains are synchronized and should be declared as false
paths during synthesis. All top-level I/O signals in the host clock domain are named with the prefix
“host_”. It is possible to use the same clock for both clock inputs can_clk and host_clk.
For CAN FD operation the clock for the CAN protocol machine can_clk shall be set to 20MHz, 40MHz or
80MHz. This is a general recommendation for all CAN FD nodes. Further details are given in chap. 4.6.
3.3 Definitions
Table 3-3 Name Definitions
Abbreviation Description
ACF Acceptance Filter
PTB Primary Transmit Buffer (high priority)
RB Receive Buffer
RDC Receiver Delay Compensation (related to TDC)
SP Sample Point
SSP Secondary Sample Point (CAN FD)
STB Secondary Transmit Buffer (low priority)
TDC Transmitter Delay Compensation (CAN FD specification)
TQ Time Quanta (CAN specification)
All register definitions are given including an access definition. Access definitions are given using an
abbreviation in the form <access>-<reset>. Possible abbreviations for the <access> attribute are “r” for
read, “w” for write and “rw” for read/write access. The <reset> attribute can be “0”, “1” and “u” for
uninitialized registers. Example: “rw-0” means “readable and writeable and reset to 0” while “r-u” means
“readable and uninitialized”. Unused bits are always r-0.
The core uses two clock domains: one for the host interface and one for the CAN protocol machine. This
enables the option to operate the CAN protocol machine with a clock that fits for the desired CAN bus
data rates best while the host is free to operate at a different (higher) clock speed.
The host interface as well as optional host interface wrappers (e.g. for AMBA busses) operate in the host
clock domain. This includes all memories and registers that are accessible using the host data bus
(chap. 3.5). Clock Domain Crossing (CDC) is done with double-buffered synchronizers and bi-directional
handshake mechanisms. The following gives some details about the CDC:
Control and status registers are moved to the appropriate clock domain individually. E.g. interrupt
flags use a bi-directional handshake while status registers use unidirectional synchronizers.
Acceptance filters are copied to the CAN clock domain during startup when bit RESET becomes
inactive. Copying the acceptance filters will be finished when the CAN node takes part in the
communication after the bus idle time.
Received frames are stored in a small temporary reception buffer. This temporary buffer holds
only parts of the frames and these parts are copied to RBUF when necessary.
Frames to be transmitted are copied step-by-step from the TBUF to a small temporary transmit
buffer.
Using synchronizers and handshake mechanisms results in some latency. Up to 3 clocks in each domain
are required for a bi-directional handshake. But in most cases for the host controller this will not be
problem.
0x9f - -
0xa0 KOER(2:0) ALC(4:0) EALCAP
0xa1 - -
0xa2 RECNT RECNT
0xa3 TECNT TECNT
0xa4 - - SELMASK - ACFADR ACFCTRL
*)
0xa5 - -
0xa6 AE_7 AE_6 AE_5 AE_4 AE_3 AE_2 AE_1 AE_0 ACF_EN_0
0xa7 AE_15 AE_14 AE_13 AE_12 AE_11 AE_10 AE_9 AE_8 ACF_EN_1
0xa8 ACODE_x or AMASK_x (7:0) ACF_0
*)
Please mind the several gaps inside the register map. This is for better address segment alignment for a
wider host controller interface.
Please have in mind that configuration registers that are only for CAN FD cannot be used if the IP core is
reduced to only CAN 2.0B capability. Then these registers are tied to their reset values.
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.
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.
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.
Writing to BITTIME_0, BITTIME_1, BITTIME_2, S_PRESC, 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. 4.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.
Reset
Bits Name Function
Value
Kind OfERror (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 reset after a successful transmission or reception of a frame.
4:0 ALC(4:0) r-0x0 Arbitration Lost Capture (bit position in the frame where the arbitration has been lost)
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 AMASK_x includes additional bits in register ACF_3 (Table 3-24) 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.
Table 3-24 Bits in Register ACF_3, if SELMASK=1
Bits Name Access Function
Acceptance mask IDE bit check enable
rw-0 1- acceptance filter accepts either standard or extended as defined by AIDE
1 AIDEE
rw-u 0- acceptance filter accepts both standard or extended frames
Only filter 0 is affected by the power-on reset. All other filters stay uninitialized.
Acceptance mask IDE bit value
If AIDEE=1 then:
rw-0
0 AIDE 1- acceptance filter accepts only extended frames
rw-u
0- acceptance filter accepts only standard frames
Only filter 0 is affected by the power-on reset. All other filters stay uninitialized.
The RBUF registers 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.
Please mind the gap inside the addressing range of RBUF from RBUF+5 to RBUF+7. This is for better
address segment alignment for a wider host controller interface.
The TBUF registers point the next empty message slot in the TB as can be seen in Figure 3-6. 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.
If the PTB is selected then the TBUF registers must not be read while a PTB transmission is active (TPE
is set). This is because the PTB data bytes are implemented as single port memory.
Both RBUF and TBUF include some frame-individual control bits (Table 3-32). 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.
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-33 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-33 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
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 FIFO-like STB (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 PTB is a single-port memory while the STB is a dual-port memory. Therefore if there is an active
transmission using the PTB (in other words TPE is set), then it is impossible for the host controller to
read the contents of the PTB. Any attempt will result in unknown results.
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 the oldest message will be overwritten by the newest and 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 overwritten.
Figure 3-9 Schematic of PTB and FIFO-like STB (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. Because of DLC
and RTR, 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 (the oldest) 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.
The interrupt EIF will be set if enabled by EIE under the following conditions:
the border of the error warning limit has been crossed in either direction by RECNT or TECNT or
the BUSOFF bit has been changed in either direction.
3.6.8.2. Arbitration Lost Capture (ALC)
The core is able to detect the exact bit position in the Arbitration Field where the arbitration has been
lost. This event can be signaled by the ALIF interrupt if it is enabled. The value of ALC stays unchanged
if the node is able to win the arbitration. Then ALC holds the old value of the last loss of arbitration.
The value of ALC is defined as follows: A frame starts with the SOF bit and then the first bit of the ID is
transmitted. This first ID bit has ALC value 0, the second ID bit ALC value 1 and so on. See Figure 2-3
for the bit order in all types of CAN 2.0 and CAN FD frames.
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.8.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 reset after a successful transmission or reception of a frame.
In Loop Back Mode the core receives its own message, stores it in the RBUF and sets the appropriate
receive interrupt flags if enabled. During a Loop Back Mode transmission ACK error generation is
disabled and the appropriate transmit interrupt will be set if enabled.
LBMI can be useful for chip-internal and software tests while LBME can test the transceiver and the
connections to it.
Both Loop Back Modes should not be activated 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.
3.6.9.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.
4.2 Definitions
The CAN bit time BT consists of several segments as shown in Figure 4-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 4-1) which
results in relationships between t Seg _ 1 , tSeg _ 2 and the maximum synchronization jump width t SJW . Please
note that Table 4-1 lists the minimum configuration ranges.
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 4-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 4-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 bits S_SJW in BITTIME_2:
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 4-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 4-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)
5. Host Interfaces
CAN-CTRL is a 32 bit peripheral component which provides a generic 32 bit host interface. Additionally
various host interface wrappers are provided. These wrappers are described in the following chapters
and can be used in addition to CAN-CTRL.
Signal host_wr_b is 4 bits wide and controls the bytes to be written. See chap. 5.1.3 for details.
The 32 bit interface provides the capability of accessing a byte, a half word or a full 32 bit word as shown
in Table 5-1. Signal host_adr is given only for completeness as the 2 LSBs are ignored by CAN-CTRL
and only the host_rd_b and host_wr_b signals are relevant.
TBUF and ACF are implemented as true 32 bit wide memories. Therefore a write access to TBUF or ACF
is only executed if it is performed as a full 32 bit word access (host_wr_b=0000b). Read accesses and
write accesses to other memory locations are not restricted.
Figure 5-3 Generic 8 Bit Wide Host Interface (only relevant signals shown)
The interface maps 8 bit wide accesses to 32 bit wide accesses. For a read operation this is
straightforward and the wrapper extracts the selected byte in the same way as shown in Figure 5-2 in a
single clock cycle.
For a write operation the wrapper needs a read-modify-write access where the full 32 bits of data are
read with the first rising edge of host_clk while signal host_ready becomes low. Then the 32 bits are
modified (the new 8 bits are embedded) and written back with the second rising edge of host_clk while
signal host_ready becomes high again. (See Figure 5-4 for details.) Therefore a write always takes two
clocks and a new write access can only be performed if signal host_ready is high.
The wrapper provides a 32 bit APB interface and executes write accesses with no wait state and read
accesses with one wait state.
The address paddr maps to the addresses of the register map (Table 3-4, chap. 3.4) with signal
host_adr. As stated in chap. 5.1 the two LSBs are ignored by CAN-CTRL.
If only one byte or some bytes shall be written then signal pstrb shall be used to mask the bytes. See
chap. 5.1.3 for details. (Signal host_wr_b maps to the inverse of pstrb.)
Attention: as defined by the APB specification pstrb only works with write accesses but not for read
accesses! Therefore always 4 bytes are read.
As stated in chap. 5.1.3 a write access to TBUF or ACF has to access a full 32 bit wide word
(pstrb=1111b). If not then an error is reported using signal pslverr and the access is not executed.
The wrapper provides a 32 bit AHB interface and executes write accesses with no wait state and read
accesses with one wait state. Please note that AHB uses a pipelined access consisting of an address
and a data phase. Both phases take 1 hclk. The data phase can be extended using wait states.
AHB is designed for high throughput. The required wait state has an impact to the system performance.
If this is a problem, then it is suggested to use the APB interface (chap. 5.3) instead of AHB.
The address haddr maps to the addresses of the register map (Table 3-4, chap. 3.4) with signal
host_adr. As stated in chap. 5.1 the two LSBs are ignored by CAN-CTRL.
AHB requires address alignment if more than one byte is accessed. For halfword accesses haddr[0]=0b
and for word accesses haddr[1:0]=00b is required. CAN_AMBA_AHB responds with an error using
signal hresp if the address alignment is wrong. A correct AHB master will never command such wrong
accesses. CAN_AMBA_AHB is a little-endian component. See chap. 5.1.3 and Table 5-2 for details.
Table 5-2 AHB Signals Mapping to CAN-CTRL
haddr[1:0] host_wr_b
hsize
host_rd_b
000b 00b 1110
000b 01b 1101
000b 10b 1011
000b 11b 0111
001b 00b 1100
001b 10b 0011
010b 00b 0000
CAN_AMBA_AHB is designed as 32 bit AHB wrapper and therefore supports byte, halfword or word
accesse (hsize = 000b, 001b or 010b). Other values are answered with an error using signal hresp.
All accesses can be made in a random way. CAN_AMBA_AHB does not require specific burst accesses
and therefore signal hburst is not used. Protected accesses (hprot) or locked accesses (hmastlock) are
not supported and therefore these signals are not used too.
Transfer types defined by htrans are supported but both types NONSEQ and SEQ will result in single
unrelated accesses. CAN_AMBA_AHB can not draw any advantage from burst accesses. Types IDLE
and BUSY will result in no access. No access will be done also if hsel=0.
Each AHB slave signals hready_out=1 if an access is completed. The AHB decoder collects all
hready_out signals from all AHB slaves and generates a final hready signal. This final hready needs to
be connected to the AHB master and to the inputs hready_in of all AHB slaves.
As stated in chap. 5.1.3 a write access to TBUF or ACF has to access a full 32 bit wide word
(hsize=010b). If not then an error is reported using signal hresp and the access is not executed.
6. Functional Description
generation of bits to transmit to the bus (ID-, RTR-, IDE-, DLC-, Data-, CRC-, …)
arbitration
error handling
7. CAN Multicore
The CAN multicore is an optional feature which can be purchased additionally.
The delivery package may include a container for multiple CAN-CTRL instances: the CAN multicore. This
container includes a generic parameter which defines the number of CAN-CTRL instances inside of the
container. All CAN-CTRL instances are connected to the same host controller data bus but provide
individual interrupt signals.
As can be seen in Figure 7-1 each CAN-CTRL instance can be connected to a separate CAN bus. As an
alternative some or all of the CAN-CTRL instances can be connected to the same CAN bus. Then it is
possible to use individual CAN bus transceivers or to connect the txd and rxd signals as shown in the
right example in Figure 7-1.
At runtime all CAN-CTRL instances are fully independent, but for synthesis all of them share the same
configuration settings in the can_package.v(hd). Therefore all instances have the same hardware
features if they are synthesized together. If it is required to have individual hardware configurations of the
CAN-CTRL instances then it is recommended to do individual synthesis for each instance and connect
them in a similar way as the CAN multicore container does it.
8. Testbenches
The testbenches can be used to test the functionality of the core during pre- and post-synthesis
simulation.
If a testbench finishes without an error then “Simulation successful!” is written to the simulator console.
Additionally to this some statistical information is given.
The testbench file list can be found in the folder /tb in Table 9-1.
8.1.1 Tbench
The “tbench” test examines the host controller interface and the most important features offered by the
core to a host. It should be noted that the complete, exhaustive testing of the core has been done for
verification purposes, but it is not fully included in the testbench delivered.
The “tbench” test presents an example CAN communication including source comments. Figure 8-1
depicts the concept of the testbench. Each node has its own clock generator and error injector. A master
(tb) controls the slave testbench processes (tbslave) for each node. There are two test vectors included:
example CAN communication, for start-up. This test is enabled when the constant (parameter)
“testvec_example” is equal 1. The “testvec_example” can be found in the header of the
tbench.v(vhd) file.
detailed set of vectors to test the most important features and to check the components
configured by the pre-synthesis settings (NR_OF_RBUFS, etc.) For more detailed test vector
description refer to the testbench source: “tbench.v(hd)”. This test is executed when the constant
(parameter) “testvec_postsyn” is equal 1. The “testvec_postsyn” can be found in the header of
the tbench.v(vhd) file.
Tests can be turned on/off and comments are included at the beginning of the testbench source code.
Search in tbench.v(hd) for the string “START HERE” to get an entry point into the test bench.
The delivery package includes only a small, but sufficient set of tests in the three-node testbench. The
CAN-CTRL core has been exhaustively tested with the three-node testbench, but these testcases are not
included in the delivery package.
The testbench for the CAN multicore verifies the system only with a very basic communication test. This
is sufficient because the CAN-CTRL core has been exhaustively tested.
11. Support
Every effort has been made to ensure that this core functions correctly. If a problem is encountered
please contact CAST:
CAST, Inc.
11 Stonewall Court
Woodcliff Lake, New Jersey 07677 USA
Technical Support Hotline: +1-201-391-8300 ext. 2
Fax: +1-201-833-2682
E-mail: [email protected]
URL: www.cast-inc.com