
The Sync_Segment is 1T
Q
. Choosing 2T
Q
for the Prop_Seg, and 7T
Q
for Phase_Seg1
leaves 6T
Q
for Phase_Seg2 and places the sampling point at 10T
Q
at the end of
Phase_Seg1.
By the rules described earlier, the SJW can be the maximum allowed (i.e., 4). However,
a large SJW is only necessary when the clock generation of different nodes is not
stable or accurate (e.g., if ceramic resonators are used). Typically, a SJW of 1 is
enough. In summary, the required timing parameters are:
Baud rate prescaler (BRP) ¼ 4
Sync_Seg ¼ 1
Prop_Seg ¼ 2
Phase_Seg1 ¼ 7
Phase_Seg2 ¼ 6
SJW ¼ 1
The sampling point is at 10T
Q
which corresponds to 62.5% of the total bit time.
There are several tools available for free on the Internet for calculating CAN bus timing
parameters. One such tool is the CAN Baud Rate Calculator, developed by Artic
Consultants Ltd (http://www.articconsultants.co.uk). An example using this tool
follows.
Example 9.3
Assuming the microcontroller oscillator clock rate is 20MHz and the required CAN
bit rate is 125KHz, calculate the timing parameters using the CAN Baud Rate
Calculator.
Solution 9.3
Figure 9.14 shows the output of the CAN Baud Rate Calculator program. The device
type is selected as PIC18Fxxx8, the oscillator frequency is entered as 20MHz, and the
CAN bus baud rate is entered as 125KHz.
Clicking the Calculate Settings button calculates and displays the recommended timing
parameters. In general, there is more than one solution, and different solutions are given
in the Calculated Solutions field’s drop-down menu.
In choosing Solution 2 from the drop-down menu, the following timing parameters are
recommended by the program:
www.newnespress.com
497Advanced PIC18 Projects—CAN Bus Projects
Comentarios a estos manuales