sandeepmistry / arduino-CAN

An Arduino library for sending and receiving data using CAN bus.
MIT License
673 stars 228 forks source link

Potential Issue when using defined CS pin #55

Open RoboticSith opened 3 years ago

RoboticSith commented 3 years ago

Hello.

I am working on a project which reads data from an attached GPS module, calculates various date/time values, displays this on a local display (4x20 LCD) and also transmits some of this information over a CAN bus for other devices to eventually read and use. I've been experimenting with several different CAN libraries for the MCP2515 (MKR CAN Shield) and this one seems the most straight forward to use, but I am running into an issue with the code hanging.

In order for the device to initialize I have to connect the CS pin to what it is defined as (I've tried both the default and a custom one by using setPins) but if I leave it connected, the whole system hangs and does nothing. disconnecting the wire allows the code to proceed. If I briefly touch the wire to the CS pin then remove it, it successfully initializes and the code runs normally (no comm though since CS is now disconnected). Connecting CS to a separate pin that I directly control as CS around when the Send functions are called does nothing. In summary, I can't control it directly yet whenever the MCP2515 CS is connected to the configured pin, the code hangs.

I started out running this on a Pro Mini 5V and I have now migrated to a Teensy 4.0 since I was exceeding the memory capacity of the pro mini. Both exhibit the same hanging issue. The MCP2515 on the Tx side is running at 3.3V and the CAN transceiver is running at 5v. Rx side is another MKR shield and an Arduino Micro (all running at 5V) printing data to a local LCD (2x16).

Any thoughts or suggestions on what is going on here? Thanks in advance.

Code is attached below. GPS_Core_v2.txt

Petros144 commented 3 years ago

Hi,

to make things easier, first make a simple programm that transmits some can data without any problem. That will show that the hardware has no prblem and the transmission lines are properly terminated (120ohms).

Do the examples work? that are included in this lib?

If you need more space for your program i can recommend you the ESP 32 witch has alredy a can controler in it, it only needs a Tranciver like TI SN65HVD230.

this combo works great for me and is dirt cheap 4$ esp32 and 4$ can tranciver.