
ADwin-Gold
USB / ENET, manual version 3.8, October 2005
37
CAN add-on
ADwin
An arriving message overwrites the old data in the message object, which will
be definitely lost. Therefore pay attention to reading out the data faster than you
are receiving them. A data loss is indicated by a flag.
The message object 15 has an additional buffer, so that 2 messages can be
stored there.
Assigning messages
The allocation of an arriving message to a message object is automatically con-
trolled by comparing its identifiers. The global mask (CAN registers 6...7 or
6...9) controls this comparison as follows:
– The identifier of the message is bit by bit compared to the identifier of the
message object. If the relevant bits are identical, the message is trans-
ferred to the message object. Not relevant bits are not compared to each
other, that is, the message is transferred to the object (if it depends on
this bit).
– Relevant bits are set in the global mask.
Global mask
With the global mask a message object is used for receiving messages with
dif-
ferent identifiers
(ID). The following example shows the assignment of the
message IDs 1...4 to the message object IDs 1...4, when all bits of the global
mask are set, except the two least-significant bits (if you have an 11-bit identifier
it is
11111111100b
).
In this example the comparison of bit 2 is responsible for the assignment of the
messages, because the bits 3...10 of the compared identifiers are identical (=
0) and the bits 0 and 1 are not compared, because they are set to zero in the
global mask (= not relevant).
Setting the bus frequency
The
CAN bus frequency
depends on the configuration of the controller.
The initialization with
INIT_CAN
configures the controller automatically to a
CAN bus frequency of 1 MHz. If the CAN bus is to operate with a different fre-
quency, the values in the "Bit Timing Register 0" (BTR0, address 3Fh) and in
the "Bit Timing Register 1" (BTR1, address 4Fh) have to be changed. Just use
the instruction
SET_CAN_BAUDRATE
for setting a large quantity of bus frequen-
cies.
With low speed CAN the maximum bus frequency is 125kBit/s.
Bus frequency for
special cases
In some special cases it may be better to select configurations other than those
set with the instruction mentioned above. For this purpose specified registers
have to be set with the instruction
POKE
. The structure of the register is
described below.
Message ID
ID of the message object
1
…001b
2
…010b
3
…011b
4
…100b
1 (
…001b
)
x
x
x
0
2 (
…010b
)
x
x
x
0
3 (
…011b
)
x
x
x
0
4 (
…100b
)
0
0
0
x
x: Message is admitted
0: Message is not admitted
Bit Timing Register 0
(BTR0)
Bit Timing Register 1
(BTR1)
Bits
7…6
5…0
7
6…4
3…0
Sub-Reg.
SJW
BRP
SPL
TSEG2 TSEG1