Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INT pin not working in LoopBackDemo example #37

Open
wavejaco opened this issue Oct 28, 2022 · 6 comments
Open

INT pin not working in LoopBackDemo example #37

wavejaco opened this issue Oct 28, 2022 · 6 comments

Comments

@wavejaco
Copy link

Hi Pierre

I am trying to use your library for an MCP2515 connected to a Raspberry Pi Pico. Using your LoopBackDemo sketch (among others), it seems that the configuration of the MCP2515 runs fine.

However, when it comes to transmitting and receiving frames, it only prints "Sent: 1" up to "Sent: 17". As you explain in the sketch's comments, this indicates to be a problem with the interrupt. I have checked the INT pin on the MCP2515 with an oscilloscope while running the sketch, and it doesn't generate an interrupt on that pin. Could there perhaps be something that is not configured correctly when the MCP2515 is initialised?

I see that in the function internalBeginOperation() you write the value 0x1F to register CANINTE, which enables the TX and RX interrupts, so I would expect the interrupt to work when the frames are sent. However, this doesn't happen.

My test is performed using a 12 MHz crystal and the Raspberry Pi Pico. The same test performed with an Arduino Due has the same result.

What could be the cause of this?

Thank you in advance.

@pierremolinaro
Copy link
Owner

pierremolinaro commented Oct 28, 2022 via email

@wavejaco
Copy link
Author

Yes, I only have the one MCP2515 at this moment.

@pierremolinaro
Copy link
Owner

pierremolinaro commented Oct 28, 2022 via email

@wavejaco
Copy link
Author

In loopback demo, the MCP2515 is configured in loopback mode, send frames are auto acked.

Does this still require at least 2x MCP2515 on the bus? I would think that it only requires 1x in loopback mode.

@pierremolinaro
Copy link
Owner

pierremolinaro commented Oct 28, 2022 via email

@wavejaco
Copy link
Author

wavejaco commented Nov 1, 2022

Hello Pierre

I have tested my setup with another microcontroller for which I wrote the code in the past to interface with the MCP2515. As I expected, the setup works perfectly fine with only 1x MCP2515 in the system when loopback mode is used. I am able to successfully send and receive a message using this setup with my own code.

The MCP2515 datasheet specifically mentions the following in section 10.4 (Loopback Mode):

In this mode, the ACK bit is ignored and the device will
allow incoming messages from itself, just as if they
were coming from another node. The Loopback mode
is a silent mode, meaning no messages will be transmitted
while in this state (including error flags or
Acknowledge signals).

Thus, to conclude, it is 100% possible to use a single MCP2515 on the CAN bus in loopback mode.

Although the setup with my own code works, I am still at the original problem with using the ACAN2515 library with the Pi Pico.

A quick thought on my side was that the 12 MHz crystal that I am using is not supported by the library. But I have even tested my own setup, deliberately specifying the wrong crystal frequency , and it still worked perfectly.

Any ideas where I could start looking for the problem with the Pi Pico use case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants