CANNY 7.3 Echo. CAN driver

General Description

The CANNY 7.3 Echo controller features two independent CAN interfaces supporting both CAN 2.0 and CAN-FD protocols. Two pairs of contacts on the controller’s 8-pin connector are designated for connection to two digital information buses, either CAN or CAN-FD: contacts No. 1 and No. 7 are used by the CAN0 interface driver (CAN0-L and CAN0-H), while contacts No. 4 and No. 6 are used by the CAN1 interface driver (CAN1-L and CAN1-H).

The CAN driver of the CANNY 7.3 Echo controller includes 16 hardware filters for each CAN interface.

The CAN0 and CAN1 interfaces have individual settings and can operate under different standards and data transfer rates, allowing the CANNY 7.3 Echo controller to connect simultaneously to two different CAN and/or CAN-FD buses.

Driver Registers

Below is a description of the valid values for the registers that control the operation of the CAN bus driver, where x denotes the CAN interface number (0 or 1).

The CAN driver configuration registers allow you to set the parameters for the controller to operate as a CAN network node on the specified CAN interface and, if necessary, limit the scope of received messages using filters:

CAN driver configuration registers.
Register Expected Values
CANx Enable Non-ISO CRC in CAN FD Frames ≥ 1 = Enable Non-ISO CRC mode for CAN FD messages on the corresponding CAN interface;
0 = Disable Non-ISO CRC mode for CAN FD messages on the corresponding CAN interface.
CANx Nominal Baud Rate Setup Register 1…N = Activate the driver and set the CAN 2.0 message transmit/receive speed (defined by a named constant from the constants list);
0 = Disable the driver for the specified CAN interface.
CANx Data Baud Rate Setup Register 1…N = Set the data transmit/receive speed for the corresponding CAN interface in CAN FD mode (defined by a named constant from the constants list);
0 = The actual data transmit/receive speed for CANx matches the set nominal speed.
CANx Mode Setup Register 0…2 = Set the operating mode of the CANx driver (defined by a named constant from the “CAN Configuration / Operating Modes” section):
0 - “CAN RX & TX Protocol CAN 2.0 A/B” - enabled by default;
1 - “CAN RX & TX Protocol CAN FD”;
2 - “CAN Interface in Listen Only Mode” - enable passive receive mode (listen only) for CAN messages on the corresponding interface (see note).
CANx Retransmission Attempts Limit ≥ 2 = Enable automatic retransmit cancellation on error for the corresponding CAN interface;
1 = Enable three attempts for automatic retransmit on error for the corresponding CAN interface;
0 = Disable automatic retransmit cancellation on error for the corresponding CAN interface.
CANx Acceptance Filter Enable Register ≥ 1 = Enable receive filtering mode for CAN messages on the corresponding interface;
0 = Disable receive filtering mode for CAN messages on the corresponding interface.
CANx Acceptance Filter
Identifier Register IDL 0

CANx Acceptance Filter
Identifier Register IDL 15
0…0xFFFF = set filter value for the lower part of the CAN-message identifier(bits 0…10 for standard identifier format or bits 0…15 for expanded identifier format) on the specified interface.
CANx Acceptance Filter
Identifier Register IDH 0

CANx Acceptance Filter
Identifier Register IDH 15
0…0x1FFF = set filter value for the upper part of the CAN-message identifier (bits 16…28 for expanded identifier format) on the specified interface.
List of permitted values for CAN configuration constants.
Parameter List of permitted values
Nominal CAN Data RX / TX Rate, kbit/s 20; 33.3; 50; 62.5; 83.3; 95.2; 100; 125; 250; 500; 666.6; 800; 1000.
CAN FD Data RX / TX Rate, kbit/s 250; 500; 1000; 2000; 4000.

Note: The “CANx Data Rate Setup Register” is only relevant in CAN FD mode and is ignored in CAN 2.0 mode. When operating in CAN FD mode with speed switching, this register must be set by the user using the appropriate named constant (see Table 2).

Note: In passive receive mode (listen only), unlike normal CAN mode, the driver receives data from the CAN bus but does not send an acknowledgment signal upon reception and does not put the network into an error state when an error is detected. Thus, the controller remains invisible to other devices on the bus. For proper CAN network operation, at least two devices operating in normal mode must be present.

Note: When receive filtering mode is enabled, the CAN driver only accepts messages whose identifiers match the values specified in the CAN message receive filter configuration registers. All other messages are ignored.

Named constants for CAN configuration parameters are available in the “CAN Baud Rates & Modes” sub-folder of the CannyLab named constants list, accessible via the context menu of the “Constant” element in the functional diagram.

CAN driver diagnostic registers let you determine the status of the driver at any given moment during diagram execution.

CAN Driver Diagnostic Registers.
Register Return Values
CANx Idle Register 1 = CAN driver activity on the specified interface is absent, the bus is idle, data reception is not performed;
0 = CAN activity on the interface registered.
CANx Overflow Register 1 = error, CAN receive buffer of the specified interface is full;
0 = no overflow of the specified interface’s receive buffer.
CANx Error Register 1 = CAN reception error rate of the specified interface exceeds the acceptable threshold;
0 = CAN reception error rate of the specified interface below the acceptable threshold.
CANx Ready To Send Register 1 = CAN driver data transmit buffer of the specified interface is empty and ready to send new messages;
0 = CAN driver data transmit buffer of the specified interface is not ready.
CANx Transmit Buffer Not Empty Register 1 = there is unsent data in the transmit buffer of the corresponding CAN driver interface;
0 = there is no unsent data in the transmit buffer of the corresponding CAN driver interface; the buffer is free.

CAN driver receive registers provide access to the values received through the CAN bus.

CAN driver receive registers.
Register Return Values
CANx Data Set Ready Register 1 = CAN driver receive buffer of the specified interface has received a message. This value appears in the register for one cycle of diagram execution and denotes that the buffer contains new actual data;
0 = there is no actual data in the CAN driver receive buffer of the specified interface.
CANx Received Data Register IDL 0…0xFFFF = value of the lower part of the identifier of the CAN message received on the specified interface.
CANx Received Data Register IDH 0…0x1FFF = value of the upper part of the identifier of the CAN message received on the specified interface.
CANx Received Data Register IEFBRL 0…0xXX40 = value equal to the number of data bytes in the received CAN message on the specified interface (see table 5) with service bits of information about special message features, where 0xXX is:
- bit 15 - IDE - extended message ID format flag;
- bit 14 - ESI - error counter overflow flag;
- bit 13 - FDF - CAN-FD message flag;
- bit 12 - BRS - CAN-FD baud rate switching usage indicator;
- bit 11 - RRS - remote data request flag.
CANx Received Data Register
D1:D0

CANx Received Data Register
D63:D62
0…0xFFFF = values of corresponding data bytes received in the CAN message on the interface, two bytes per register.

Note: The maximum CAN message length is 64 bytes (in CAN FD mode), which corresponds to 0x40 in hexadecimal.

CAN FD Message Data Byte Values.
Parameter List of permitted values
Number of data bytes in a CAN FD message 0; 1; 2; 3; 4; 5; 6; 7; 8; 12; 16; 20; 24; 32; 48; 64.

CAN transmit registers are used to place data that you want to send into the transmission buffer.

CAN driver transmit registers.
Register Expected values
CANx Request To Send Register ≥ 1 = load data from the transfer registers into the CAN driver transmission buffer of the specified interface;
0 = do not load data into the CAN driver transmission buffer of the specified interface.
CANx Transmit Data Register IDL 0…0xFFFF = value of the lower part of the identifier of the CAN-message being transmitted on the specified interface.
CANx Transmit Data Register IDH 0…0x1FFF = value of the upper part of the identifier of the CAN-message being transmitted on the specified interface.
CANx Transmit Data Register ERL 0…0xXX40 = value equal to the number of data bytes in the transmitted CAN message on the specified interface (see table 5) with service bits of information about special message features, where 0xXX is:
- bit 15 - IDE - extended message ID format flag;
- bit 14 - ESI - error counter overflow flag;
- bit 13 - FDF - CAN-FD message flag;
- bit 12 - BRS - CAN-FD baud rate switching usage indicator;
- bit 11 - RRS - remote data request flag.
CANx Transmit Data Register
D1:D0

CANx Transmit Data Register D63:D62
0…0xFFFF = values of the corresponding data bytes of the CAN message being transmitted on the specified interface, two bytes per register.

Note: The maximum CAN message length is 64 bytes (in CAN FD mode), which corresponds to 0x40 in hexadecimal.

Message reception examples

Example 1: Receiving Data from the CAN0 Bus in CAN 2.0 A/B Mode

The controller executes the diagram, receiving messages in standard format with identifier 0x0123 containing one byte of data. It sets two outputs based on the received value.

Example of a functional diagram for receiving data from the CAN0 bus.

Example 2: Receiving Data from the CAN0 Bus in CAN FD Mode

The controller executes the diagram, receiving messages in standard format with identifier 0x0123 in CAN FD mode, containing 64 bytes of data. It analyzes byte D40 and sets two outputs accordingly.

Example of a functional diagram for receiving data from the CAN0 bus in CAN FD mode.

Note: In the CAN0 IEFBRL register, additional service bits indicating special message attributes are checked (i.e., whether the received message is a CAN FD message transmitted with a speed change).

Example 3: Receiving Data from the CAN0 Bus in CAN FD Mode with Filtering

The controller receives messages over the bus, compares their identifiers with the values specified in the CAN0 message filter setup registers. If they match, it transfers the message contents to the CAN0 receive registers for processing in the functional diagram and briefly activates its green LED. Messages whose identifiers do not match the filter settings are automatically discarded, reducing controller resource consumption and enhancing uninterrupted reception of necessary messages.

Example of a functional diagram for receiving data from the CAN0 bus in CAN FD mode with filtering.

Note: Filter No. 2 and Filter No. 3 settings may correspond to messages with multiple identifiers, allowing one filter to receive and process groups of messages with the specified parameters.

Message transmission examples

Example 1: Transmitting Data to the CAN0 Bus in CAN 2.0 A/B Mode

The controller executes the diagram periodically (every 100 ms), transmitting data to the bus at 125 kbps. It sends the state of two inputs using standard format messages with identifier 0x123 containing one byte of data.

Example of a functional diagram for transmitting data to the CAN0 bus in CAN 2.0 A/B mode.

Example 2: Transmitting Data to the CAN0 Bus in CAN FD Mode

The controller executes the diagram periodically (every 100 ms), transmitting data to the CAN0 bus in CAN FD mode with speed switching (nominal CAN speed of 500 kbps, data transmit speed of 2 Mbps). It sends the state of two inputs using standard format messages with identifier 0x123 containing one byte of data.

Example of a functional diagram for transmitting data to the CAN0 bus in CAN FD mode.

Note: The diagram illustrates how to form the CAN0 IEFBRL register with the appropriate service bits for message attributes (i.e., that the message is a CAN FD message in standard format transmitted with a speed change). In general, instead of forming this register, you can simply set it to the constant 0x3010, which defines all parameters of the transmitted message.

Example 3: Transmitting an Extended Format CAN Message in CAN FD Mode

Example of a functional diagram for transmitting a CAN message in CAN FD mode, 16 bytes long, with an extended identifier 0x1f110001: 0xDE 0xAD 0xBE 0xEF 0x12 0x34 0x56 0x78 0xDE 0xAD 0xBE 0xEF 0x12 0x34 0x56 0x78 upon a signal appearing on the controller’s zeroth channel.

To transmit a 16-byte CAN message in CAN FD mode with an extended identifier, you must set the CAN message identifier, including its upper part [CAN0 Transmit Data Register IDH]; set bits 15, 13, and 12 of the [CAN0 Transmit Data Register IEFBRL]; and specify the number of bytes in the transmitted message in the [CAN0 Transmit Data Register IEFBRL].

Example of a functional diagram for transmitting an extended format CAN message in CAN FD mode.

Example 4: Periodic Transmission of Multiple CAN Messages

Example of a functional diagram for periodic transmission of multiple messages.

The controller sequentially transmits a group of 8 messages with a 1-second interval between them. Seven messages are transmitted in CAN 2.0 A/B mode, while the message with ID=0x008 (index=3) and 12 bytes long is transmitted in CAN FD format.

Note: To organize periodic transmission of multiple CAN messages, you can also use the CAN Asynchronous Transmission Driver.

SEE ALSO