View previous topic :: View next topic |
Author |
Message |
mutthunaveen
Joined: 08 Apr 2009 Posts: 100 Location: Chennai, India
|
Basic CAN implementation starting questions |
Posted: Sun Oct 02, 2011 8:53 am |
|
|
Hello Board
I planned to start learning CAN communication with 18F877A and MCP2515 and CCS compiler...
Past 2 days I was searching on ccs forum and on internet and I finally have 2 questions before i really get into hardware connections.
I have 2x16F877A PICs and 3 MCP2515 CAN controllers.
Now my question is
1. When I see the driver code <can-mcp251x.c> the PIN connection to my PIC is as follows:
Code: |
#define EXT_CAN_CS PIN_B1
#define EXT_CAN_SI PIN_C1
#define EXT_CAN_SO PIN_C0
#define EXT_CAN_SCK PIN_C3
|
But here the MCP2515 works on SPI and these 3 C0, C1, C2 (16F877A) datasheet they are not belonging to SPI as written there in datasheet..
by connecting to these pins will my code work fine ? (communicating CAN IC in SPI).
2. Do I really need MCP2551 for communication CAN between PICs ?
3. Do I have to connect a external oscillator for the MCP2515 IC (or we can give the clock by software i mean in CCS) ?
4. What I have to do for the unused pins in MCP2515 (like TX1RTS etc) ?
5. Finally can I set CAN ID for a MCP2515 using 16F877A (in CCS) and extended CAN ID for the same chip and is communication possible between CAN and ECAN (will this be possible) ?
Please answer my poor basic questions, thank you board. And this may also helpful for all the beginners like me.... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Sun Oct 02, 2011 11:21 am |
|
|
I don't use CAN but..
1) looks like the driver is using those pins to interface with the CAN interface chip using software SPI. Any 4 pins could be used, depends on overall design.
2)yes, if you're using the CAN protocol/design then you need to use CAN compatible interface chips....
3)The CAN chip datasheet will describe the all specific CAN requirements.
4)see #3 above
5)again see #3 or any official CAN documentation
i suggest a lot more reading, especially on CAN protocol, hardware,timing,etc. Lots of information out there... |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Sun Oct 02, 2011 11:47 am |
|
|
temtronic wrote: | I don't use CAN but.. |
you CAN....
BAHAHAHAHAHAHAHAHAHA.... (running away now) _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Oct 02, 2011 2:43 pm |
|
|
Quote: |
3. Do I have to connect a external oscillator for the MCP2515 IC
(or we can give the clock by software i mean in CCS) ?
|
You could possibly do that, but I'm not sure how you get a high speed
clock from the PIC without trying to use the PIC's crystal for both chips.
Some hobbyists do that, but I would never do it. Or you could use an
external oscillator for both. When I designed a board with a MCP2510
on it a few years ago, I put separate crystals (and caps) on each chip.
I wanted total reliability.
But see the thread below. It explains how on the CCS CAN bus board,
they have a 20 MHz crystal (and capacitors) on the MCP2510. Then they
take the CLKOUT pin of the MCP2510 and use it to drive the PIC's
oscillator input pin. They run the PIC from the oscillator on the CAN bus
controller:
http://www.ccsinfo.com/forum/viewtopic.php?t=30485
Quote: |
4. What I have to do for the unused pins in MCP2515 (like TX1RTS etc) ? |
The three TX*RTS pins can be left unconnected. |
|
|
mutthunaveen
Joined: 08 Apr 2009 Posts: 100 Location: Chennai, India
|
for the conclusion |
Posted: Tue Oct 04, 2011 12:32 am |
|
|
Hello board thanks very much for your valuable responses.
Here are the concluding parameters
1. answer is YES
Quote: | by connecting to these pins will my code work fine ? (communicating CAN IC in SPI).
|
2. answer is YES
Quote: | Do I really need MCP2551 for communication CAN between PICs ?
|
3. answer is YES
Quote: | Do I have to connect a external oscillator for the MCP2515 IC (or we can give the clock by software i mean in CCS) ?
|
4. answer is ==> we can leave unconnected if not used
Quote: | What I have to do for the unused pins in MCP2515 (like TX1RTS etc) ?
|
5. answer ==> better if we use a additional xtal for reliable working
Quote: | Finally can I set CAN ID for a MCP2515 using 16F877A (in CCS) and extended CAN ID for the same chip and is communication possible between CAN and ECAN (will this be possible) ?
|
Correct me if i am wrong and if there some improvements plz mention |
|
|
|