ADwin-Gold II
, Manual February 2013
33
CAN Interface
ADwin
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 frequency, just use the
instruction
Set_CAN_Baudrate
.
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
Set_CAN_Baudrate
. For this purpose specified registers have to be set with the
instruction
Poke
. The structure of the register is described in the controller documen-
tation.
Enable Interrupt / Trigger Event
A message object can be enabled to trigger an interrupt when a message arrives. The
interrupt output of the CAN controller is connected to the event input of the processor.
The processor reacts immediately to incoming messages without having to control the
message input (polling).
You can enable the interrupts of several message objects. Which object has caused the
interrupt can be seen in the interrupt register (
5Fh
): It contains the number of the mes-
sage object that caused the interrupt. If the interrupt flag (new message flag) is reset in
the message object, the interrupt register will be updated. If there is no interrupt the reg-
ister is set to 0. If another interrupt occurs during working with the first interrupt its
source will be shown in the interrupt register. An additional interrupt does not occur in
this case.
Programming
The interface is easily programmed using ADbasic instructions:
The instructions are in the include file <
ADwinGoldII
.INC>. More information can also
be found in the ADbasic manual and the online help.
Range
Instructions
Initialization
Init_Can
En_Interrupt
Set_Can_Baudrate
Receiving and sending of data
Can_Msg
En_Receive
,
En_Transmit
Read_Msg
,
Read_Msg_Con
Transmit
Write / read access to the
controller register
Set_Can_Reg
Get_Can_Reg