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

Cannot get CAN library and SPI display (ILI9341) working at the same time #52

Open
RBVGH opened this issue Aug 26, 2020 · 4 comments
Open

Comments

@RBVGH
Copy link

RBVGH commented Aug 26, 2020

I am working on an Arduino MKR Zero based project that combines an MKR CAN Shield as well as a touch screen (2.4” 240x320 using the Adafruit ILI9341 library).

When connected alone, the CAN Shield works fine using the Sandeep Mistry's arduino-CAN library and the CANSender code. When connected alone, the display assembly also works fine.

But I do not get both parts working at the same time. When running CANSender, it gives a “Starting CAN failed!” error message in SerialReader.

I checked whether there was a conflict on resources. The CAN board uses SPI with Chip Select (CS) on port 3, the display and touch panel use SPI with CS on pin A3 and A4 respectively. So, there should not be any conflict of resources there. The CAN board also uses interrupt on Pin 7, which is not used by the display or touch panel.

Interestingly, when I power up with just the CAN shield first, wait for successful initialisation, and THEN connect the display module, the CAN bus traffic continues to work fine (again using just CANSender, no code for the display at all). But when I power up with both connected, everything else equal, I get the above error. So it seems only the initialisation phase that has problems, not the later communication phase.

Am not really a programmer… Anyone any clue or suggestion how to get this working?

Thanks!!

@timurrrr
Copy link

A good starting point would be to figure out what exactly fails.
Try opening the source code of the arduino-CAN library installed into your Arduino IDE, follow the code that you call before you get the failure, and insert something line Serial.println("Failed doing XYZ"); at each block of code like if (not ok) { return ...; }. This way you should be able to find out which condition fails.
This is how I found the bug here: #45

@RBVGH
Copy link
Author

RBVGH commented Aug 28, 2020

Thanks Timurrr for the reply. I should indeed try that, but it's rather complicated as the CAN library in turn calls other libraries (such as those for the SPI bus) and the problem may be there.

I also have another lead: the SCK signal looks rather degraded when the display and touch chips are connected to the SPI bus (voltage drop, reduced slew rate). Just connecting these to the SCK bus even when MISO and MOSI are disconnected results in an initialisation failure of the CAN shield. I may need to look further (regenerate clock by an additional chip, or reduce clock rate).

@Petros144
Copy link

What kind of CAN tranciver /controler are you useing? I also work with the same TFT Driver in my project and have zero problems.

I use the onboard ESP32 Can Controller and a SN65HVD230 tranciver... this may be a better solution for your purpose?

@timurrrr
Copy link

timurrrr commented Sep 6, 2020

Just connecting these to the SCK bus even when MISO and MOSI are
disconnected results in an initialisation failure of the CAN shield.

Yeah, sounds like you need to figure out a way to better isolate them electrically.

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

3 participants