Miscellaneous Topics

# Message Flags

The following flags can be returned from canRead() et al, or passed to canWrite(). Note that you can combine one or more flags, and you can also combine them with the flags below.

Flag | Value | Meaning
--- | --- | ---
canMSG_RTR | 1 | Message is a remote request
canMSG_STD | 2 | Message has a standard (11-bit) identifier
canMSG_EXT | 4 | Message has a extended (29-bit) identifier
canMSG_WAKEUP | 8 | Message is a WAKEUP message (SWC hardware.)
canMSG_ERROR_FRAME | 32 | Message represents an error frame.

The following flags can be returned from canRead() et al, but cannot be passed to canWrite():

Flag | Value | Meaning
--- | --- | ---
canMSG_NERR | 16 | NERR was active during the message (TJA1054 etc. hardware. See Note 4 below.)/tr>
canMSG_TXACK | 64 | Message is a TX ACK (meaning that the message was really sent)/tr>
canMSG_TXRQ | 128 | Message is a TX REQ (meaning that the message was transferred to the CAN controller)/tr>
canMSGERR_HW_OVERRUN | 512 | Hardware buffer overrun.
canMSGERR_SW_OVERRUN | 1024 | Software buffer overrun.

Note
  Other canMSG_xxx and canMSGERR_xxx flags are reserved and must be zero when calling canWrite().
  Not all hardware platforms can detect the difference between hardware overruns and software overruns, so your application should test for both conditions. You can use the symbol canMSGERR_OVERRUN for this purpose.
  All canMSG_xxx flags may be combined.
  The NERR flag is set by the CAN transceiver when certain CAN bus wire faults occur, namely

1 | CANH wire interrupted
2 | CANL wire interrupted
3 | CANH short-circuited to battery
3a | CANH short-circuited to VCC
4 | CANL short-circuited to ground
5 | CANH short-circuited to ground
6 | CANL short-circuited to battery
6a | CANL short-circuited to VCC
7 | CANL and CANH mutually short-circuited

See the TJA1054 data sheet (available from Philips) for more detailed information.

# Bit Rate Constants

Constant | Bit rate | Sampling point | SJW | Quanta per bit
--- | --- | --- | --- | ---
canBITRATE_1M synonym: BAUD_1M | 1 Mbit/s | 62.5% | 1 | 8
canBITRATE_500K synonym: BAUD_500K | 500 kbit/s | 62.5% | 1 | 8
canBITRATE_250K synonym: BAUD_250K | 250 kbit/s | 62.5% | 1 | 8
canBITRATE_125K synonym: BAUD_125K | 125 kbit/s | 68.7% | 1 | 16
canBITRATE_100K synonym: BAUD_100K | 100 kbit/s | 68.7% | 1 | 16
canBITRATE_83K synonym: BAUD_83K | 83.333 kbit/s | 75% | 2 | 8
canBITRATE_62K synonym: BAUD_62K | 62.5 kbit/s | 68.7% | 1 | 16
canBITRATE_50K synonym: BAUD_50K | 50 kbit/s | 68.7% | 1 | 16
canBITRATE_10K | 10 kbit/s | 75% | 1 | 16

If you want to set a bit rate other than those you find above, you can use canSetBusParams() or canSetBusParamsC200().

Note
  Bit rates below 50 kbit/s are not available with certain hardware that uses the TJA1050 transceiver.

# Code and Mask Format

Explanation of the code and mask format used by the canAccept(), and canObjBufSetFilter() functions: A binary 1 in a mask means "the corresponding bit in the code is relevant"

A binary 0 in a mask means "the corresponding bit in the code is not relevant"

A relevant binary 1 in a code means "the corresponding bit in the identifier must be 1"

A relevant binary 0 in a code means "the corresponding bit in the identifier must be 0"

In other words, the message is accepted if ((code XOR id) AND mask) == 0.

Note
  You can set the extended code and mask only on CAN boards that support extended identifiers.
  Not all CAN boards support different masks for standard and extended CAN identifiers.
  If you want to remove a filter, call canAccept with the mask set to 0.
  On some boards the acceptance filtering is done by the CAN hardware; on other boards (typically those with an embedded CPU,) the acceptance filtering is done by software. canAccept behaves in the same way for all boards, however.