Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

CANBus / MCP2515 question

Status
Not open for further replies.

Sam Jelfs

New Member
Hiya, has anyone any experience of using an MCP2515? I'm trying to get a CAN system working, to communicate between two 16F873A PIC's using MCP2515 CAN Controllers and MCP2551 Transceivers.

At the moment I'm trying to sort out the SPI interface and not having much luck, so would be grateful if there is anyone around with any knowledge that could give me a quick guide on how to do it all. I'm currently sending a load tx buffer command, then a read command, but not getting anything on the SDO line from the 2515, do I need to set the control registers first?

Cheers

Sam J
 
If you are asking about the CAN registers, then no. If you are asking about the SPI registers, then yes. The MCP2515 will need a slave select signal from the processor before it will pay any attention to SDI(MOSI) and SCK. I don't have the datasheet handy but it might be called Slave Select (SS-bar). The next thing to worry about is on the SPI interface you must choose one of four formats which are selected by bits in the SPI control register called Clock PHase(CPHA) and Clock Polarity(CPOL). You also need to decide on a baudrate for the SPI and you must make sure that the MCP2515 can handle it.

When you say that there is "nothing" on the SDO line are you saying that it is driven "high" always, driven "low" always", or floating. What should it be under various conditions?
 
Ah, i think I have it working, I have set the SSPSTAT and SSPCON registers in the pic, and have it in mode 0,0 at Fosc / 64, though this was just to make monitoring it with a logic analyser a bit easier. The MCP2515 can handle either mode 0,0 or 1,1 and at up to a max clock of 10MHz. as the crystal for my PIC is only 10MHz, thats not going to be an issue.
the SDO line is always driven low, but I think that has was being caused by issues within the MCP2515, ie the control registers not being correctly initialised.

If you / anyone knows the MCP2515 I would be grateful if you could look over my code, tell me if I'm making some stupid mistakes, as I inevitably will be, lol.

Cheers

Sam J
 
There are two possibilities for SDO and you have to read the datasheet carefully.
  1. The SPI interface on the MCP2515 is designed to be daisy chained inwhich case SDO will float until and unless the MCP2515 is selected and has been requested to send data.
  2. It is driven, but in an idle state until it has been commandd to send data. In this case a single 74HC125 buffer can transform a non tri-state output into one that is. The enable is the same as Slave Select(SS-bar).
Since you say the SPI interface can do either format 0,0 or 1,1, I'm curious as to how it selects one or the other. If there is some configuration then how can you configure it with the interface you are configuring?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top