View previous topic :: View next topic |
Author |
Message |
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
18F26K80 CAN bit rates 250 and 500 |
Posted: Mon Oct 07, 2013 3:01 am |
|
|
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
|
|
Posted: Mon Oct 07, 2013 3:22 am |
|
|
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: 9221 Location: Greensville,Ontario
|
|
Posted: Mon Oct 07, 2013 5:28 am |
|
|
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
|
|
Posted: Mon Oct 07, 2013 5:36 am |
|
|
Compiler 5.012
And all the code is from the j1939 example of ccs |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
newguy
Joined: 24 Jun 2004 Posts: 1907
|
|
Posted: Mon Oct 07, 2013 11:28 am |
|
|
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
|
|
Posted: Mon Oct 07, 2013 12:51 pm |
|
|
Thanks mate. I already tried It. Still the 500k doesn't work. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19500
|
|
Posted: Mon Oct 07, 2013 1:32 pm |
|
|
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 |
|
|
|