- BRP0..BRP5 sets the clock prescaler value
- SJW0..SJW1 sets the length of the SJW
- TSEG10..TSEG13 sets the number of quanta before the sampling
point (the start bit is not included)
- TSEG20..TSEG22 sets the number of quanta after the sampling
point.
- SAM is set to 1 if three samples is to be obtained and to 0
if one sample is enough.
Note: the actual value of these parameters is one more than
the value written into the register.
Example: if the oscillator signal fed to the SJA1000 is 16 MHz, and we want a bit rate of 250 kbit/s, with a sampling
point close to 62% of the whole bit, and a SJW of 2 quanta, we
can set -
BRP = 4, which gives a quantum length of 2 * 4
/ 16000000 s = 500 ns, and
TSEG1 = 5, which gives 5 quanta before the sampling point, and
TSEG2 = 3, which gives 3 quanta after the sampling point.
Each bit will then comprise 5 + 3 = 8 quanta,
which results in the desired bit rate of 1 / (8 * 500 ns) = 250
kbit/s. The register values should then be -
| btr0 = |
(SJW - 1) * 64 + (BRP -1) =
(2-1)*64 +
(4-1) =
67 =
0x43 |
| btr1 = |
SAM * 128 + (TSEG2 - 1)* 16 + (TSEG1 - 1) =
0*128 + (3-1)*16
+ (4-1) = ("4" because the start bit isn't
included)
35 =
0x23
|
The sampling point is at 5/8 = 62.5% of a bit.
|