SLAU723A October 2017 – October 2018 MSP432E401Y , MSP432E411Y
The CAN system supports bit rates in the range of lower than 1 kbps up to 1000 kbps. Each member of the CAN network has its own clock generator. The timing parameter of the bit time can be configured individually for each CAN node, creating a common bit rate even though the CAN nodes' oscillator periods may be different.
Because of small variations in frequency caused by changes in temperature or voltage and by deteriorating components, these oscillators are not absolutely stable. As long as the variations remain inside a specific oscillator's tolerance range, the CAN nodes are able to compensate for the different bit rates by periodically resynchronizing to the bit stream.
According to the CAN specification, the bit time is divided into four segments (see Figure 11-4): the Synchronization Segment, the Propagation Time Segment, the Phase Buffer Segment 1, and the Phase Buffer Segment 2. Each segment consists of a specific, programmable number of time quanta (see Table 11-2). The length of the time quantum (tq), which is the basic time unit of the bit time, is defined by the CAN controller's input clock (fsys) and the Baud Rate Prescaler (BRP):
tq= BRP / fsys
The fsys input clock is the system clock frequency as configured by the RSCLKCFG register (see Section 4.2.11).
The Synchronization Segment Sync is that part of the bit time where edges of the CAN bus level are expected to occur; the distance between an edge that occurs outside of Sync and the Sync is called the phase error of that edge.
The Propagation Time Segment Prop is intended to compensate for the physical delay times within the CAN network.
The Phase Buffer Segments Phase1 and Phase2 surround the Sample Point.
The (Re)Synchronization Jump Width (SJW) defines how far a resynchronization may move the Sample Point inside the limits defined by the Phase Buffer Segments to compensate for edge phase errors.
A given bit rate may be met by different bit-time configurations, but for the proper function of the CAN network, the physical delay times and the oscillator's tolerance range must be considered.
Parameter | Range | Remark |
---|---|---|
BRP | [1 to 64] | Defines the length of the time quantum tq. The CANBRPE register can be used to extend the range to 1024. |
Sync | 1 tq | Fixed length, synchronization of bus input to system clock |
Prop | [1 to 8] tq | Compensates for the physical delay times |
Phase1 | [1 to 8] tq | May be lengthened temporarily by synchronization |
Phase2 | [1 to 8] tq | May be shortened temporarily by synchronization |
SJW | [1 to 4] tq | May not be longer than either Phase Buffer Segment |
The bit timing configuration is programmed in two register bytes in the CANBIT register. In the CANBIT register, the four components TSEG2, TSEG1, SJW, and BRP must be programmed to a numerical value that is one less than its functional value; so instead of values in the range of [1 to n], values in the range of [0 to n-1] are programmed. That way, for example, SJW (functional range of [1 to 4]) is represented by only two bits in the SJW bit field. Table 11-3 shows the relationship between the CANBIT register values and the parameters.
CANBIT Register Field | Setting |
---|---|
TSEG2 | Phase2 – 1 |
TSEG1 | Prop + Phase1 – 1 |
SJW | SJW – 1 |
BRP | BRP |
Therefore, the length of the bit time is (programmed values):
[ TSEG1 + TSEG2 + 3] tq
or (functional values):
[Sync + Prop + Phase1 + Phase2] tq
The data in the CANBIT register is the configuration input of the CAN protocol controller. The baud rate prescaler (configured by the BRP field) defines the length of the time quantum, the basic time unit of the bit time; the bit timing logic (configured by TSEG1, TSEG2, and SJW) defines the number of time quanta in the bit time.
The processing of the bit time, the calculation of the position of the sample point, and occasional synchronizations are controlled by the CAN controller and are evaluated once per time quantum.
The CAN controller translates messages to and from frames. In addition, the controller generates and discards the enclosing fixed format bits, inserts and extracts stuff bits, calculates and checks the CRC code, performs the error management, and decides which type of synchronization is to be used. The bit value is received or transmitted at the sample point. The information processing time (IPT) is the time after the sample point needed to calculate the next bit to be transmitted on the CAN bus. The IPT includes any of the following: retrieving the next data bit, handling a CRC bit, determining if bit stuffing is required, generating an error flag or simply going idle.
The IPT is application-specific but may not be longer than 2 tq; the IPT of the CAN is 0 tq. Its length is the lower limit of the programmed length of Phase2. In case of synchronization, Phase2 may be shortened to a value less than IPT, which does not affect bus timing.