Книга: Advanced PIC Microcontroller Projects in C

9.7 Nominal Bit Timing

9.7 Nominal Bit Timing

The CAN bus nominal bit rate is defined as the number of bits transmitted every second without resynchronization. The inverse of the nominal bit rate is the nominal bit time. All devices on the CAN bus must use the same bit rate, even though each device can have its own different clock frequency. One message bit consists of four nonoverlapping time segments:

• Synchronization segment (Sync_Seg)

• Propagation time segment (Prop_Seg)

• Phase buffer segment 1 (Phase_Seg1)

• Phase buffer segment 2 (Phase_Seg2)

The Sync_Seg segment is used to synchronize various nodes on the bus, and an edge is expected to lie within this segment. The Prop_Seg segment compensates for physical delay times within the network. The Phase_Seg1 and Phase_Seg2 segments compensate for edge phase errors. These segments can be lengthened or shortened by synchronization. The sample point is the point in time where the actual bit value is located and occurs at the end of Phase_Seg1. A CAN controller can be configured to sample three times and use a majority function to determine the actual bit value.

Each segment is divided into units known as time quantum, or TQ. A desired bit timing can be set by adjusting the number of TQ’s that comprise one message bit and the number of TQ’s that comprise each segment in it. The TQ is a fixed unit derived from the oscillator period, and the time quantum of each segment can vary from 1 to 8. The lengths of the various time segments are:

• Sync_Seg is 1 time quantum long

• Prop_Seg is programmable as 1 to 8 time quanta long

• Phase_Seg1 is programmable as 1 to 8 time quanta long

• Phase_Seg2 is programmable as 2 to 8 time quanta long

By setting the bit timing, a sampling point can be set so multiple units on the bus can sample messages with the same timing.

The nominal bit time is programmable from a minimum of 8 time quanta to a maximum of 25 time quanta. By definition, the minimum nominal bit time is 1?s, corresponding to a maximum 1Mb/s rate. The nominal bit time (TBIT) is given by:

TBIT = TQ * (Sync_Seg + Prop_Seg + Phase_Seg1 + Phase_Seg2)  (9.1)

and the nominal bit rate (NBR) is

 NBR = 1/TBIT  (9.2)

The time quantum is derived from the oscillator frequency and the programmable baud rate prescaler, with integer values from 1 to 64. The time quantum can be expressed as:

 TQ = 2 * (BRP + 1)=FOSC  (9.3)

where TQ is in ?s, FOSC is in MHz, and BRP is the baud rate prescaler (0 to 63).

Equation (9.2) can be written as

TQ = 2 * (BRP + 1) * TOSC  (9.4)

where TOSC is in ?s.

An example of the calculation of a nominal bit rate follows.

Example 9.1

Assuming a clock frequency of 20MHz, a baud rate prescaler value of 1, and a nominal bit time of TBIT=8*TQ, determine the nominal bit rate.

Solution 9.1

Using equation (9.3),

 TQ = 2 * (1 + 1)/20 = 0.2?s

also

 TBIT = 8 * TQ = 8 * 0.2 = 1.6?s

From Equation (9.2),

 NBR = 1/TBIT = 1/1.6?s = 625.000bites/s or 625Kb/s

In order to compensate for phase shifts between the oscillator frequencies of nodes on a bus, each CAN controller must synchronize to the relevant signal edge of the received signal. Two types of synchronization are defined: hard synchronization and resynchronization. Hard synchronization is used only at the beginning of a message frame, when each CAN node aligns the Sync_Seg of its current bit time to the recessive or dominant edge of the transmitted start of frame. According to the rules of synchronization, if a hard synchronization occurs, there will not be a resynchronization within that bit time.

With resynchronization, Phase_Seg1 may be lengthened or Phase_Seg2 may be shortened. The amount of change in the phase buffer segments has an upper bound given by the synchronization jump width (SJW). The SJW is programmable between 1 and 4, and its value is added to Phase_Seg1 or subtracted from Phase_Seg2.

Оглавление книги


Генерация: 1.061. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз