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

Basic CAN implementation starting questions

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



Joined: 08 Apr 2009
Posts: 100
Location: Chennai, India

View user's profile Send private message

Basic CAN implementation starting questions
PostPosted: Sun Oct 02, 2011 8:53 am     Reply with quote

Hello Board

I planned to start learning CAN communication with 18F877A and MCP2515 and CCS compiler... Cool
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.... Arrow
temtronic



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

View user's profile Send private message

PostPosted: Sun Oct 02, 2011 11:21 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Oct 02, 2011 11:47 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Oct 02, 2011 2:43 pm     Reply with quote

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

View user's profile Send private message

for the conclusion
PostPosted: Tue Oct 04, 2011 12:32 am     Reply with quote

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