
CAN add-on
ADwin
36
ADwin-Gold
USB / ENET, manual version 3.8, October 2005
9.2.2 Description of the CAN interface
The CAN bus interface is equipped with the Intel
®
CAN controller AN82527
which works according to the specification CAN 2.0 parts A and B as well as
to ISO 11898. You program the interface with
ADbasic
instructions, which are
directly accessing the controller’s registers.
Message
Messages sent via CAN bus are data telegrams with up to 8 bytes, which are
characterized by so-called identifiers. The CAN controller of the DIO1 add-on
supports identifiers with a length of 11 bit and 29 bit. The communication, that
means the management of bus messages, is effected by 15 message objects.
The 255 registers are used for configuration and status display of the CAN con-
troller. Here the bus speed and interrupt handling, etc. are set (see separate
documentation "82527 - Serial Communications Controller, Architectural Over-
view" by Intel
®
)
The CAN bus can be set to frequencies of up to 1 MHz and is usually operated
with 1MHz; with low speed CAN the max. frequency is 125kHz. The CAN bus
is galvanically isolated by optocouplers from the
ADwin
system.
An arriving message can trigger an interrupt which instantaneously generates
an event at the processor. Therefore an immediate processing of messages is
guaranteed.
Message Management
Identifier
The CAN controller identifies messages by an identifier; these are parameters
in a defined bit length. The parameters 0...2
11
-1 or 0...2
29
-1 result from the bit
length.
Message objects
The controller stores each message (incoming or outgoing) in one out of 15
message objects. The message objects can either be configured to send or to
receive messages. Message object 15 can only be used to receive messages.
After initializing the CAN controller all message objects are not configured.
Each message object has an identifier, which enables the user to assign a
message to a message object.
Transferring messages
In
ADbasic
a message is transferred to a message object using the array
can_msg
[][]
, which can receive 8 data bytes plus the amount of data bytes
(9 elements). When reading a message from the message object it can also be
transferred to the array
can_msg
[][]
.
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.