Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

CAN Implementation Using PIC16F877A and MCP2515

Status
Not open for further replies.

Jestin_cubetech

Advanced Member level 1
Joined
Jun 24, 2012
Messages
499
Helped
76
Reputation
152
Reaction score
73
Trophy points
1,328
Activity points
3,699
CAN Implementation Using PIC16F877A , MCP2515 CAN controller and MCP2551 CAN Transceiver.


3 Nodes
CAN NODE A,CAN NODE B and CAN NODE C



this example shows..

CAN NODE A request ADC data from CAN NODE B
CAN NODE B send ADC value to CAN NODE A.



CAN NODE A request ADC data from CAN NODE B
CAN NODE C send ADC value to CAN NODE A.



CAN NODE A Send LED SET/CLEAR commands to CAN NODE B



CAN NODE A Send LED SET/CLEAR commands to CAN NODE C




controller : PIC16F877A
C compiler : PIC CCS
Schematic and PCB Designing Tool : Proteus

http://ww1.microchip.com/downloads/en/devicedoc/21801e.pdf
http://users.ece.utexas.edu/~valvano/Datasheets/MCP2551.pdf

- - - Updated - - -

circuit diagram
 
Last edited:

Joined
Jul 25, 2012
Messages
1,192
Helped
170
Reputation
340
Reaction score
161
Trophy points
1,343
Activity points
0
Can you post the proteus file and hex file so that I can simulate and see.
 

skara1214

Newbie level 5
Joined
Oct 12, 2009
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,334
yes could you please give the code ?
 

jekim

Newbie level 2
Joined
May 31, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,288
please, post the library of mcp2551.
thanks!
 

Jestin_cubetech

Advanced Member level 1
Joined
Jun 24, 2012
Messages
499
Helped
76
Reputation
152
Reaction score
73
Trophy points
1,328
Activity points
3,699
install PIC-CCS

library location

C:\Program Files\PICC\Drivers\can-mcp251x.c
C:\Program Files\PICC\Drivers\can-mcp251x.h
 

jekim

Newbie level 2
Joined
May 31, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,288
hello, I have two PIC18F458 communicate through can and wanted to pass this on to pic18f258 since they are smaller and spare space on pcb but does not work when I try to do it.
is there any difference in the pic can libraries.
Thanks!!
 

laksprecitron

Newbie level 3
Joined
Jun 21, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,301
Hello Jestin,

I went through your blog. From the .C files used in your project, we find that the code developed by you is I2C code and the SPI is not used. From the MCP2515 datasheet, we find that the IC supports only SPI communication. Kindly enlighten on your project.

We are using a PIC16F876 and MCP2515 CAN IC. We are not able to establish the connection via SPI.
 

Jestin_cubetech

Advanced Member level 1
Joined
Jun 24, 2012
Messages
499
Helped
76
Reputation
152
Reaction score
73
Trophy points
1,328
Activity points
3,699
PICC MCP header file mcp251x.c
------------------------------------------
C:\Program Files\PICC\Drivers\can-mcp251x.c
it use SPI Protocol not i2c.
 

laksprecitron

Newbie level 3
Joined
Jun 21, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,301
Can i have the can-mcp251x.c file
I could not locate any spi initiation etc.,


PICC MCP header file mcp251x.c
------------------------------------------
C:\Program Files\PICC\Drivers\can-mcp251x.c
it use SPI Protocol not i2c.
- - - Updated - - -

The can-mcp251x.c and can-mcp2510.c are the same files.

The below function from can-mcp251x.c. The code is of I2C and not the SPI.

Code:
void mcp2510_command(int command) {
   int i;

   output_low(EXT_CAN_CS);

   for (i=0;i<8;i++) {
      output_bit(EXT_CAN_SI, shift_left(&command,1,0));
      output_high(EXT_CAN_SCK);
      output_low(EXT_CAN_SCK);
   }

   output_high(EXT_CAN_CS);
}
 
Last edited by a moderator:

Jestin_cubetech

Advanced Member level 1
Joined
Jun 24, 2012
Messages
499
Helped
76
Reputation
152
Reaction score
73
Trophy points
1,328
Activity points
3,699



1, EXT_CAN_CS for Chip Select
2, EXT_CAN_SCK Clock input
3, EXT_CAN_SI Data pin
 

laksprecitron

Newbie level 3
Joined
Jun 21, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,301
Hello Jestin,

Could you kindly let us know what state do we need keep the TXnRTS pins to enable transmission. We are using two nodes now. When we try to send data from one node to another, the data gets loaded onto the TXBUF but does not go on the CAN bus. The TXBUF remains full thereafter. With the second node, there is no interrupts / RXBUF flags are not set.
 

laksprecitron

Newbie level 3
Joined
Jun 21, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,301
Is it possible to analyse my code and suggest me the modifications? I am using a PIC16F876 controller with MCP2515. My project is compiled with CCS.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top