Softing CAN-AC2-104 with Philips SJA1000 FIFO Write

Softing CAN-AC2-104 with Philips SJA1000 FIFO Write block


Simulink® Real-Time™ Library for CAN


The FIFO Write driver block writes CAN messages into the transmit FIFO. The firmware running in FIFO mode then processes the information in the transmit FIFO and finally puts the constructed CAN messages onto the bus. This block dynamically detects the data type and signal size of the signal that you connect to the input port.

If you use the CAN_MESSAGE data type:

If the block input is a CAN_MESSAGE data type, use CAN Pack blocks to pack individual signals into a CAN message. If you use CAN Pack blocks to prepare each message, the FIFO Write block reads the CAN_MESSAGE data. To combine several messages into a vector of CAN_MESSAGE data that the FIFO Write block sends, use a Mux block. Use the Port (if input is CAN_MESSAGE) parameter to select the port to which to send the CAN_MESSAGE data.

    Tip   To prepare a remote frame, use the CAN Pack block with the Remote frame check box selected. To request the current value, send the remote frame to the responding subsystem.

If you use the double data type (legacy):

If the block input consists of double values in a matrix, the block has one input port of type double. At this port, you must provide the elements required to construct valid CAN messages to be written into the transmit FIFO. For each CAN message, five elements have to be passed:


The value can be either 1 (port 1) or 2 (port 2) and defines at which port the CAN message is sent from.


Identifier of the CAN message to be sent. If it is a standard CAN message, the valid range is 0 to 2047. If extended, the range is 0 to 229-1.

Identifier type

The value can be either 0 (standard identifier range) or 1 (extended identifier range) and defines the identifier type of the outgoing CAN message.

Data frame size

The value can be in the range of 0 to 8 and defines the data frame size in bytes of the outgoing CAN message


Data for the data frame itself. Use the CAN Bit-Packing block to construct the data as double values in a matrix.

Because this information can be dynamically changed in FIFO mode during real-time application execution, the information is provided at the block input instead of using the block parameters. To transmit more than one CAN message per block instance, use a matrix signal as a container.

The dimension of the matrix signal entering the block must be n*5, where n is the number of CAN messages to be sent by this block instance. Therefore, each row of the matrix signal defines one CAN message and each row combines the five elements of information defined above (in this order).

For examples of constructing the matrix signal for the FIFO write block, see CAN FIFO Loopback Tests.

For certain models, you might make the writing of a CAN message into the transmit FIFO dependent on the model dynamics. For this, the matrix signal can also be of dimension n*6 instead of n*5. In this case, the sixth column defines whether the corresponding CAN message is written into the transmit FIFO (value 1) or not (value 0).

Block Parameters


Defines the board used to send the CAN messages defined by this block instance. For more information about the meaning of the board number, see the Setup driver block described above. If just one board is present in the target system, select board number 1.

Show input count port

Select this check box to track the number of inputs to the block and add a second input port, N, to the block. If this port value exceeds the size of the input vector of CAN_MESSAGE messages, the block limits the transfer to the size of the input vector. If this port value is smaller than the CAN_MESSAGE input vector size, the block transfers data up to the size of this port value. For example, assume an input of 10*5 matrix. If you then input a 5 to input port N, the block sends only the first five messages. In an n*6 matrix, the last entry in the row is still the individual message enabled, but the block checks only messages up to n. If the input is a matrix of doubles, the block ignores the value of the Port parameter. The block considers the port as part of the data.

If this check box is cleared, the block sends all elements of the input vector.

Port (if input is CAN_MESSAGE)

If the message is a CAN_MESSAGE data type, from the list, select 1 or 2 for the port to send the message through. The block sends a message to a single CAN port. If you want to send messages to different ports in a model, use multiple FIFO Write blocks. This input port is the first one on the block. Its input is a vector or single CAN_MESSAGE message.

If the message consists of double values in a matrix, changing this parameter does not change block behavior. You specify the port number in the CAN message. A single FIFO Write block can send messages through both ports.

Show status output port

Selecting this check box lets you enable the status output port. If the box is cleared (disabled), the block does not have an output port. If enabled, a port is shown. The signal leaving the block is a vector of type CAN_MESSAGE or double depending on which data type you are using for your messages. The number of elements depends on the signal dimension of the block input port. There is one element for each CAN message written into the transmit FIFO and the value is identical to the return argument of function CANPC_send_data, described in the Softing® user manual. Refer to that manual for more information. The function return codes are:



Function executed without detecting an error.


Function encountered an error.


Timeout firmware communication.


Board not initialized.

Sample time

Defines the sample time at which the FIFO Write block is executed during a real-time application run.

You can use as many instances of the FIFO Write block in the model as required. For example, by using two instances of the block with different sample times, you can send CAN messages out at different rates. Or you can use multiple instances to structure your model more efficiently.

Was this topic helpful?