ADwin-Pro
Hardware, manual version 2.9, June 2006
173
Pro I: Signal Conditioning and Interface Modules
Pro-CAN-x Rev. A
ADwin
Sending messages
Sending a message is made as follows:
– You configure a message object to send and define the identifier of the
object (instruction
EN_TRANSMIT
).
– Save the message in
can_msg
[]
.
– Send the message (instruction
TRANSMIT
). The message in the array
can_msg
[]
is transferred to the message object. As soon as the bus is
ready, the message is sent (with the identifier of the message object).
Receiving messages
Receiving a message is made as follows:
– You configure a message object to receive and define the identifier of
the object (instruction
EN_RECEIVE
).
– The controller monitors the CAN bus if there are incoming messages
and saves messages with the right identifier in the message object.
– Transfer the message from the message object into the array
can_msg
[]
(instruction
READ_MSG
) and read out the corresponding
identifier.
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
controlled 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
different 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 identi-
fier 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).
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