CAN add-on
ADwin
38
ADwin-Gold
USB / ENET, manual version 3.8, October 2005
The following table shows the admitted values and the meaning of the individ-
ual ranges:
The default setting of the ranges SJW and SPL is 0 and should only be
changed if necessary. Select the sample point (specified by TSEG1 and
TSEG2) in such a way that it is between 50% and 80% of the total bit length.
The CAN bus frequency is calculated as follows:
The following table illustrates all common settings for the Baud rates.
Access to the two timing registers is only possible, when the access has been
enabled before. This is done by the CCE-bit in the control register. The bit has
to be reset afterwards.
Interrupt / 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 mes-
sages 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 message 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 register 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:
Range
Admitted
values
Meaning
SJW
0 … 3
Max. pulse elongation during bus synchronization
BRP
0 … 63
Pre-scaler
SPL
0 … 1
Sampling mode
TSEG1
2 … 15
Time segments before sampling
TSEG2
1 … 7
Time segments after sampling
Baud rate [kBit/s]
125
250
500
1.000
BRP
3
1
0
0
TSEG1
6
6
6
2
TSEG2
7
7
7
3
BTR0
03h
01h
00h
00h
BTR1
76h
76h
76h
32h
Sample point[%]
54
54
54
60
Fig. 29 – CAN: Setting the Baud rates
Range
Instructions
Initialization
INIT_CAN
EN_INTERRUPT
SET_CAN_BAUDRATE
f
CAN
8MHz
BRP 1
+
(
)
TSEG1 TSEG2 3
+
+
(
)
----------------------------------------------------------------------------------------
=