RichM
Joined: 23 Jun 2008 Posts: 1
|
CAN bus rate |
Posted: Thu Jul 24, 2008 6:10 am |
|
|
I'm using PIC18F2685-I/S0 at 16Mhz and want to run a CANBUS at 250K.
I can't see how to figure out the settings I need for the CAN bus. I believe I have to override the following values (defaulted for 125K) in can18XXX.h
Code: |
#IFNDEF CAN_BRG_SYNCH_JUMP_WIDTH
#define CAN_BRG_SYNCH_JUMP_WIDTH 0 //synchronized jump width (def: 1 x Tq)
#ENDIF
#IFNDEF CAN_BRG_PRESCALAR
#define CAN_BRG_PRESCALAR 4 //baud rate generator prescalar (def: 4) ( Tq = (2 x (PRE + 1))/Fosc )
#ENDIF
#ifndef CAN_BRG_SAM
#define CAN_BRG_SAM 0 //sample of the can bus line (def: bus line is sampled 1 times prior to sample point)
#endif
#ifndef CAN_BRG_PHASE_SEGMENT_1
#define CAN_BRG_PHASE_SEGMENT_1 5 //phase segment 1 (def: 6 x Tq)
#endif
#ifndef CAN_BRG_PROPAGATION_TIME
#define CAN_BRG_PROPAGATION_TIME 2 //propagation time select (def: 3 x Tq)
#endif
#ifndef CAN_BRG_PHASE_SEGMENT_2
#define CAN_BRG_PHASE_SEGMENT_2 5 //phase segment 2 time select (def: 6 x Tq)
#endif
|
I've found section 23.9 (CAN) Baud Rate Setting in the PIC18F2685 manual no help, just more confusing.
I'm not sure what all the above macros define, how come the CAN_BRG_SYNCH_JUMP_WIDTH is 0, how can a width be 0, is it actually not a width and a point in the sequence? Simply does not seem to make sense.
Is there an accesible way to do this without having to dig through layers of specs?
P.S. Just to make matters worse, I'm inerfacing to a Pentium3 running vxWorks, so I don't really have the option of back-to-back testing. |
|