Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

CAN Implementation Using PIC16F877A and MCP2515

Status
Not open for further replies.

Jestin_cubetech

Advanced Member level 1
Advanced Member level 1
Joined
Jun 24, 2012
Messages
499
Helped
76
Reputation
152
Reaction score
73
Trophy points
1,328
Visit site
Activity points
3,697
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

**broken link removed**
https://users.ece.utexas.edu/~valvano/Datasheets/MCP2551.pdf

- - - Updated - - -

circuit diagram
 
Last edited:

Files:



unfortunately MCP2515 simulation is not available in Proteus...
 

Attachments

  • CAN_hex_files_and_simulations.zip
    4.1 MB · Views: 945

this project developed from PIC-CCS CAN example program.
Location: C:\Program Files\PICC\Examples
 

Attachments

  • PIC-CCS CAN Example.rar
    14.4 KB · Views: 650

install PIC-CCS

library location

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

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

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.
 

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

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:

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.
 

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top