MCP2515 won't send on CAN bus.

Author
francis_jeffries
Starting Member
  • Total Posts : 73
  • Reward points : 0
  • Joined: 2015/11/24 09:35:02
  • Location: 0
  • Status: offline
2018/11/09 09:49:39 (permalink)
0

MCP2515 won't send on CAN bus.

I am driving a 2515 using a PIC 16F1824. I am configuring the 2515 correctly, as far as I am aware. I have configured CF1, CF2, and CF3 and not much else, for example, because I want only to transmit. I  have set CANCTRL to change the clockout frequency and that happens, so I'm sure I'm writing to the device successfully.
I can load all the 8 TXB0.. transmit buffers and read them back out again to be sure they loaded. 
I have tried using the SPI RTS command to send the 8 buffers on the CAN bus, but nothing comes out. I have tried loading the TXB0CTRL register directly with 0x0D to force transmit of the buffers, but nothing comes out. And I've tried using BIT MODIFY to do the same thing. All to no avail.
If I read the TXB0CTRL register, it's holding 0x00, not 0x0D. Has anyone any suggestion as to how to make it work, please?
 
#1

9 Replies Related Threads

    Jim Nickerson
    User 452
    • Total Posts : 5447
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: online
    Re: MCP2515 won't send on CAN bus. 2018/11/09 10:14:23 (permalink)
    0
    I wonder if there is anything else on this CAN buss ?
    #2
    francis_jeffries
    Starting Member
    • Total Posts : 73
    • Reward points : 0
    • Joined: 2015/11/24 09:35:02
    • Location: 0
    • Status: offline
    Re: MCP2515 won't send on CAN bus. 2018/11/09 11:42:14 (permalink)
    0
    There isn't anything else on the CAN bus - yet - apart from the 120-ohm terminating resistor. The device is fitted to a Microchip MCP2515_CAN development pcb.
    Should I have another device on the bus to make it active? It seems rather improbable.
    #3
    Jim Nickerson
    User 452
    • Total Posts : 5447
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: online
    Re: MCP2515 won't send on CAN bus. 2018/11/09 11:46:24 (permalink)
    0
    francis_jeffries
    There isn't anything else on the CAN bus - yet - apart from the 120-ohm terminating resistor. The device is fitted to a Microchip MCP2515_CAN development pcb.
    Should I have another device on the bus to make it active? It seems rather improbable.


    Yes though you think not indeed at least two devices are required on the bus.


    #4
    Jim Nickerson
    User 452
    • Total Posts : 5447
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: online
    Re: MCP2515 won't send on CAN bus. 2018/11/09 11:48:49 (permalink)
    0
    This page Architecture, Physical might provide some clues https://en.wikipedia.org/wiki/CAN_bus
    #5
    francis_jeffries
    Starting Member
    • Total Posts : 73
    • Reward points : 0
    • Joined: 2015/11/24 09:35:02
    • Location: 0
    • Status: offline
    Re: MCP2515 won't send on CAN bus. 2018/11/09 12:08:04 (permalink)
    0
    I looked up the reference and notice that the bus needs 120-Ohm terminations at both ends. I have only a single termination resistor of 120-Ohms fitted to the pins on the pcb. Maybe I should put 60-Ohms instead until I have a real bus to connect to.
     
    But I can't believe that wrong impedances would affect the values read from TXB0CTRL, surely? 
    #6
    Jim Nickerson
    User 452
    • Total Posts : 5447
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: online
    Re: MCP2515 won't send on CAN bus. 2018/11/09 12:16:29 (permalink)
    0
    I have found on short test runs ( inches ) I can get sometimes away without the 120 ohm at all.
    CAN is an interesting protocol.
    If you do not have a second device you might try loopback mode.
    If you can get the device configured and enter normal mode you are doing well.
    In normal mode after configuration the error condition is entered very quickly.
    I suspect from power on with a fast ( depending on your baud rate ) scope/logic analyzer you might see something transmitted on the bus as it awaits the ACK bit and retries before stopping and entering error mode.
    Do ensure you test for and handle all error conditions.
    #7
    JPortici
    Super Member
    • Total Posts : 432
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re: MCP2515 won't send on CAN bus. 2018/11/09 12:22:48 (permalink)
    5 (1)
    francis_jeffries
    Should I have another device on the bus to make it active? It seems rather improbable.



    Yes. It is a requisite for CANBUS that there are at least two nodes. a message is successfully sent if an ACK is generated by all the other nodes in the bus. A node that is not currently transmitting will generate an ACK if the current message is correctly formed, regardless if the device has a filter active for its ID.
    So, if there is only one node there isn't any node that can generate an ACK and no message will be transmitted.
     
    Of course, there is loopback mode, but that's uninteresting (you don't see what actually happens) and if no other devices are present i usually see one attempt to send a message, then only error frames that are never ACK'd until the transmit error counter is full and the controller goes into error mode, no more transmissions.
    post edited by JPortici - 2018/11/09 12:25:02
    #8
    francis_jeffries
    Starting Member
    • Total Posts : 73
    • Reward points : 0
    • Joined: 2015/11/24 09:35:02
    • Location: 0
    • Status: offline
    Re: MCP2515 won't send on CAN bus. 2018/11/10 12:53:08 (permalink)
    0
    Ah ha! That makes sense. I'll work on that next week with another node connected.
    Thanks very much - I'll report on progress.
    #9
    francis_jeffries
    Starting Member
    • Total Posts : 73
    • Reward points : 0
    • Joined: 2015/11/24 09:35:02
    • Location: 0
    • Status: offline
    Re: MCP2515 won't send on CAN bus. 2018/11/13 08:06:00 (permalink)
    0
    I've had another look at this, and still can't get a result. 
    I load the output registers TXB0D0 to TXB0D7 with different values. I then send the value 0b00001011 to TXB0CTRL, which should send (because bit 3, TXREQ, is set) the contents of the registers to the CAN bus. I can read the contents of all the registers back and they are all as previously loaded.
    I read back the contents of TXB0CTRL and it returns 0b00000000. I expected to see error flags in the high nibble. But I am amazed to discover that the two priority bits I loaded into TXB0CTRL (0b11) have been cleared!
    What can I be doing wrong?
    #10
    Jump to:
    © 2018 APG vNext Commercial Version 4.5