CAN
This page documents the CAN configuration.
Configuration file fields
This section is autogenerated from the Rule Schema file.
Bit-rate configuration mode phy.can.bit_rate_cfg_mode
Configures how the CAN bus bit-rate is set. Bit-rate supports all standard bit-rates. Non-standard bit-rate configuration can be set using Bit-timing.
Type | Default | Options |
---|---|---|
integer | 0 | Bit-rate (simple): |
Bit_rate_std phy.can.bit_rate_std
Bit_rate_fd phy.can.bit_rate_fd
Configuration explained
This section contains additional information and examples.
The input clock to the CAN-bus controller is set to 40MHz.
The bit-rate mode Bit-rate (simple)
supports the following list of bit-rates[1]:
Bitrate |
BRP |
Quanta |
Seg1 |
Seg2 |
SJW |
---|---|---|---|---|---|
5000 |
100 |
100 |
63 |
16 |
4 |
10000 |
50 |
100 |
63 |
16 |
4 |
20000 |
25 |
100 |
63 |
16 |
4 |
33333 |
10 |
120 |
95 |
24 |
4 |
47619 |
8 |
105 |
83 |
21 |
4 |
50000 |
10 |
80 |
63 |
16 |
4 |
83333 |
4 |
120 |
95 |
24 |
4 |
95238 |
4 |
105 |
83 |
21 |
4 |
100000 |
5 |
80 |
63 |
16 |
4 |
125000 |
4 |
80 |
63 |
16 |
4 |
250000 |
2 |
80 |
63 |
16 |
4 |
500000 |
1 |
80 |
63 |
16 |
4 |
800000 |
1 |
50 |
39 |
10 |
4 |
1000000 |
1 |
40 |
31 |
8 |
4 |
2000000 |
1 |
20 |
15 |
4 |
4 |
4000000 |
1 |
10 |
7 |
2 |
2 |
In bit-rate mode Bit-timing (advanced)
, the bit-rate timing can be set directly. The following equations can be used to calculate the bit-timing fields:
Input clock: \(CLK = 40\text{ MHz}\)
Quanta: \(Q = 1 + SEG_1 + SEG_2\)
Bit-rate: \(BR = \frac{CLK/BRP}{Q}\)
Sample point: \(SP = 100 \cdot \frac{1 + SEG_1}{Q}\)
Examples
Example: Matching bit-timing settings based on different input clock frequency (CLK
).
Settings to match (based on a 80MHz input clock):
Bit-rate: 2M
Quanta: 40
SEG1: 29
SEG2: 10
Sample point: 75%
Above settings are based on an input clock with frequency:
The CANmod.gps uses a 40MHz input clock. To obtain a bit-rate of 2 M with a 40 MHz input clock, the number of quanta is calculated as:
To obtain a sampling point of 75%, SEG1 is calcualted as:
Now, SEG2 is calculated as:
The equivalent bit-timing settings using the 40 MHz input clock of the CANmod.gps becomes:
BRP: 1
SEG1: 14
SEG2: 5