P2 with canbus and sd card

Hello,

We will use the P2 with a SD card (502774-0891), and also with CAN bus (MCP25625)
The P2 has two SPI, how should we connect them?
SD card to SPI and canbus to SPI1? Or other way around?

Or is it possible to connect to eg to SPI1?
Will it be stable with the libraries, eg with callback functions?

What about the speed? Does it make any difference if SD card to SPI and canbus to SPI1?
Or both to the SPI1?

What is the best practice?

Thank you for your help.

Generally speaking, you can have multiple devices on the same SPI bus. The CAN bus library is definitely compatible, as there are a large number of devices on the Tracker SPI bus.

The SDFat library is compatible if you’ve enabled transaction support in the library.

The two SPI busses are different speeds:

  • SPI uses the RTL872x SPI1 peripheral (25 MHz maximum speed)
  • SPI1 uses the RTL872x SPI0 peripheral (50 MHz maximum speed)

I would typically use a single SPI bus with multiple devices instead of two busses.

The main exception is that if you have one SPI peripheral that does very lengthy transactions, and one that requires low latency. That is sort of the case with SD card and CAN, since SD card erase sector can take some time to execute, and you may want to perform CAN operations at the same time. This would require separate SPI busses. However, depending on how you are using CAN, this may or may not be an issue.

Thank you so much Rick! I think will make it on two different buses. I let you know our experience later.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.