This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Softing CAN-AC2-104 with Philips SJA1000 FIFO Read

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


Simulink® Real-Time™ Library for CAN


The FIFO Read driver block reads CAN messages from the receive FIFO. The firmware running in FIFO mode puts received events (CAN messages) into the receive FIFO. From here, the FIFO Read driver reads out the events. The receive FIFO can store up to 127 events (messages). If it is full and a FIFO Read driver block does not attempt to read the stored events, the driver ignores new incoming events. Increments to the lost message counter tally the lost messages. You can use the FIFO Read RCV Level driver block to check for this condition and perform an error action. For example, you can stop the execution or reset the receive FIFO.

If you choose CAN_MESSAGE data type as the output, use CAN Unpack blocks to unpack individual signals from a CAN message.

    Tip:   To process a remote frame, use the CAN Unpack block with the Output remote check box selected to enable the Remote port. When the Remote port becomes true, send the current value to the requesting subsystem.

If you choose matrix as the output data type, the FIFO Read driver block has one output port of type double. The signal of this port is a matrix of size m*6, where m is the FIFO read depth defined in the block parameters. For example, if the FIFO read depth is 5, the matrix signal of port 1 has size 5*6. Therefore, the matrix contains one row for each event read from the receive FIFO (no new message is considered as an event as well). For examples of extracting data from the matrix signal, see CAN FIFO Loopback Tests.

If you choose output as double values in a matrix, each row with its six elements contains the information defining a CAN message:


The value is either 1 (port 1) or 2 (port 2) and reports the port at which the CAN message was received.


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

Event type

Defines the type of event read from the receive FIFO. The following values are defined from the Softing® user manual:



No new event.


Standard data frame received.


Standard remote frame received.


Transmission of a standard data frame is confirmed.



Change of bus state.




Transmission of a standard remote frame is confirmed.


Extended data frame received.


Transmission of an extended data frame is confirmed.


Transmission of an extended remote frame is confirmed.


Extended remote frame received.




Error frame detected.

Data frame size

If a data frame has been received, the length of the data in bytes is reported by this element. Possible values are 0 to 8.


Reports the time at which the event was received. The resolution of the timestamp counter is 1μs.


Data of the data frame itself. It is returned as a CAN_MESSAGE or double value (8 bytes) depending on which data type you are using for your messages. Use the CAN Pack to extract data from the CAN_MESSAGE data. Use the CAN Bit-Unpacking block to extract the data from the double value.

Block Parameters


Defines the board to use 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. If just one board is present in the target system, select board number 1.

Output format

From the list, select:

  • Matrix of doubles (legacy)

    Formats messages as double values in a matrix. See Description for details on this message format.

  • Vector of CAN_MESSAGE plus count

    Formats messages as vectors of CAN_MESSAGE structures.

    Selecting this option enables the Port parameter. It also creates an N output port that contains the number of valid entries in the CAN_MESSAGE data vector. The block interprets the FIFO read depth value as the size of the vector. The block outputs up to FIFO read depth number of messages. For example, if you enter a read depth of 3, but the receive FIFO has only two messages, the output vector has only two messages. The CAN I/O FIFO Mode - Simple Use Case (with CAN_MESSAGE) example illustrates the use of this parameter.

  • Function call for each CAN_MESSAGE

    Formats messages as vectors of CAN_MESSAGE structures.

    Selecting this option enables the Port parameter. It also creates a function-call output (f()) output port. This port contains a function-call for a single CAN_MESSAGE data element. The block repeats the function-call for each message from the FIFO, up to the value of FIFO read depth. You input this function-call output into a function-call subsystem. The CAN I/O FIFO Mode - Simple Use Case (with CAN_MESSAGE and Function Call Output) example illustrates the use of this parameter.


CAN_MESSAGE only. From the list, select 1 or 2 for the input port. The block reads the message from that FIFO (1 or 2). Its output is a vector of CAN_MESSAGE messages. If you want to read from both ports, use two FIFO Read blocks, one for each port. Selecting Vector of CAN_MESSAGE plus count for Output format enables this parameter.

Selecting Matrix of doubles (legacy) or Function call for each CAN_MESSAGE for the Output format parameter disables this parameter. The block ignores the port. In this case, the block reads from both ports and records the port for each message in the output matrix.

FIFO read depth

Defines the number of receive FIFO read attempts. Each time the block is executed, it reads this fixed number of events (CAN messages), which leads to a deterministic time behavior independent of the number of events currently stored in the receive FIFO. The read depth (m) also defines the size of the matrix signal (m*6) leaving the first output port. If an event is not currently stored in the receive FIFO, the FIFO is read anyway, but the event type is reported as 0 (no new event).

Show status output port

Lets you enable the status output port (S). If the box is cleared (disabled), the block has one output port for events. If enabled, a second port is shown. The signal leaving that port is a vector of doubles, with two elements:

[Number of lost messages (events), Bus state]

The first element returns the current value of the lost messages counter. The receive FIFO can store up to 127 events. If the receive FIFO is not regularly accessed for reading events, the FIFO is filled and the lost messages counter starts to increment. This is an indicator that events (messages) will be unavoidably lost. The second element returns the current bus state. Possible values are



Error active


Error passive


Bus off

Sample time

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

    Note:   Use only one instance of this block per physical CAN board in your model. Otherwise, one instance can read events that are intended for blocks connected to another instance.

See Also

Introduced in R2006a

Was this topic helpful?