CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

CAN bus rate

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
RichM



Joined: 23 Jun 2008
Posts: 1

View user's profile Send private message

CAN bus rate
PostPosted: Thu Jul 24, 2008 6:10 am     Reply with quote

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.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 24, 2008 9:23 am     Reply with quote

Quote:

Is there an accesible way to do this without having to dig through layers
of specs?

Yes. See my post in the middle of this thread.
http://www.ccsinfo.com/forum/viewtopic.php?t=22138
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group