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.

FlagValueMeaning
canMSG_RTR1Message is a remote request
canMSG_STD2Message has a standard (11-bit) identifier
canMSG_EXT4Message has a extended (29-bit) identifier
canMSG_WAKEUP8Message is a WAKEUP message (SWC hardware.)
canMSG_ERROR_FRAME32Message represents an error frame.

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

FlagValueMeaning
canMSG_NERR16NERR was active during the message (TJA1054 etc. hardware. See Note 4 below.)/tr>
canMSG_TXACK64Message is a TX ACK (meaning that the message was really sent)/tr>
canMSG_TXRQ128Message is a TX REQ (meaning that the message was transferred to the CAN controller)/tr>
canMSGERR_HW_OVERRUN512Hardware buffer overrun.
canMSGERR_SW_OVERRUN1024Software 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
  
1CANH wire interrupted
2CANL wire interrupted
3CANH short-circuited to battery
3aCANH short-circuited to VCC
4CANL short-circuited to ground
5CANH short-circuited to ground
6CANL short-circuited to battery
6aCANL short-circuited to VCC
7CANL and CANH mutually short-circuited

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

Bit Rate Constants

ConstantBit rateSampling pointSJWQuanta per bit
canBITRATE_1M
synonym: BAUD_1M
1 Mbit/s62.5%18
canBITRATE_500K
synonym: BAUD_500K
500 kbit/s62.5%18
canBITRATE_250K
synonym: BAUD_250K
250 kbit/s62.5%18
canBITRATE_125K
synonym: BAUD_125K
125 kbit/s68.7%116
canBITRATE_100K
synonym: BAUD_100K
100 kbit/s68.7%116
canBITRATE_83K
synonym: BAUD_83K
83.333 kbit/s75%28
canBITRATE_62K
synonym: BAUD_62K
62.5 kbit/s68.7%116
canBITRATE_50K
synonym: BAUD_50K
50 kbit/s68.7%116
canBITRATE_10K10 kbit/s75%116

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.