View previous topic :: View next topic |
Author |
Message |
Animok
Joined: 03 May 2018 Posts: 11
|
CAN BUS & PIC18F248 |
Posted: Thu Nov 08, 2018 1:23 pm |
|
|
Hello everyone.
A simple question:
Can I use EX_J1939.c with PIC18F248?
This example refer to PIC18F4580.h why?
Regards |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19559
|
|
Posted: Fri Nov 09, 2018 1:31 am |
|
|
Potentially with a bit of tweaking. Obviously you have to setup the clock and fuses etc., to match.
Key is in the PIC18 can driver (can-18F4580.c), where it carefully says:
Quote: |
CAN Library routines for Microchip's PIC18Cxx8 and 18Fxx8 line
|
The 248, has the 'standard' CAN peripheral, not the ECAN peripheral, but the driver supports a 'legacy' mode to support this.
Problem comes in j1939.c, where there is the section:
Code: |
#else //PIC18
can_set_mode(CAN_OP_CONFIG); //put CAN in Config mode
can_set_functional_mode(CAN_FUN_OP_ENHANCED_FIFO);
|
You'll have to change this to CAN_FUN_OP_LEGACY.
The driver can work with this, since it is used if running with an external chip. So it ought then to run.... |
|
|
Animok
Joined: 03 May 2018 Posts: 11
|
|
Posted: Fri Nov 09, 2018 3:06 am |
|
|
Thanks Ttelmah.
I wil try it.
However, what about PIC18F25K80 ?
It have ECAN, is it better option?
Regards |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19559
|
|
Posted: Fri Nov 09, 2018 5:00 am |
|
|
Yes. With the fuses set right that is directly compatible. |
|
|
|