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 CCS Technical Support

18F26K80 CAN bit rates 250 and 500

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



Joined: 13 Nov 2012
Posts: 219
Location: France

View user's profile Send private message

18F26K80 CAN bit rates 250 and 500
PostPosted: Mon Oct 07, 2013 3:01 am     Reply with quote

Hi all,

I have this chip working at 125kbit/s, but no matter what I try, I can't get it to work at 250 or 500 kbit/s.

I have a 16 MHz xtal, ad 4x pll, so clock is 64 MHz.

Settings for 125 kbit:

CAN_BRG_PRESCALAR 15
CAN_BRG_PROPAGATION_TIME 2
CAN_BRG_PHASE_SEGMENT_1 7
CAN_BRG_PHASE_SEGMENT_2 3

Can anyone share their working settings for 250 and 500 please?
oxo



Joined: 13 Nov 2012
Posts: 219
Location: France

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 3:22 am     Reply with quote

OK, so now i have settings for 250kbit, #

I dropped the pll, so clock is now 16 MHz.

Code:
These work for 250.
#define CAN_BRG_PRESCALAR           1
#define CAN_BRG_PROPAGATION_TIME    4
#define CAN_BRG_PHASE_SEGMENT_1     7
#define CAN_BRG_PHASE_SEGMENT_2     1


Code:
and in theory, these should work for 500, but they don't
#define CAN_BRG_PRESCALAR           0
#define CAN_BRG_PROPAGATION_TIME    4
#define CAN_BRG_PHASE_SEGMENT_1     7
#define CAN_BRG_PHASE_SEGMENT_2     1
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 5:28 am     Reply with quote

I don't have that PIC but general comments...

It could be a 'bug' in your compiler version, that's why it's important to tell us what you're running.

Also, dump out the listing and confirm the correct register is being set/cleared according to the PICs datasheet.

Since you're only changing...#define CAN_BRG_PRESCALAR 1 ...
it should be easy to find and see what's happening.

It might be that ' CAN_BRG_PRESCALAR ' is being changed twice unknown to you, from 'extra' code that shouldn't be there....

hth
jay
oxo



Joined: 13 Nov 2012
Posts: 219
Location: France

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 5:36 am     Reply with quote

Compiler 5.012

And all the code is from the j1939 example of ccs
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 11:20 am     Reply with quote

Quote:
Can anyone share their working settings for 250 and 500 please?

Download and install the MBtime can bus baud rate calculator:
http://www.intrepidcs.com/support/mbtime.htm

Detailed instructions on how to use it with CCS:
http://www.ccsinfo.com/forum/viewtopic.php?t=22138&start=8
newguy



Joined: 24 Jun 2004
Posts: 1908

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 11:28 am     Reply with quote

Further to what PCM has posted, I had a lot of trouble with the CCS CAN functions with later version 4 compilers (4.100+) and dsPICs. I ended up having to completely set up the CAN registers myself. I have no experience with the version 5 compiler yet.
oxo



Joined: 13 Nov 2012
Posts: 219
Location: France

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 12:51 pm     Reply with quote

PCM programmer wrote:
Quote:
Can anyone share their working settings for 250 and 500 please?

Download and install the MBtime can bus baud rate calculator:
http://www.intrepidcs.com/support/mbtime.htm

Detailed instructions on how to use it with CCS:
http://www.ccsinfo.com/forum/viewtopic.php?t=22138&start=8


Thanks mate. I already tried It. Still the 500k doesn't work.
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 1:32 pm     Reply with quote

Other thing to remember is that as frequencies get higher, so do the requirements to keep bus capacitance's low, terminate properly, etc. etc..

Best Wishes
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