SLAAEN5 February   2025 MSPM0G1106 , MSPM0G1107 , MSPM0G1506 , MSPM0G1507 , MSPM0G1518 , MSPM0G1519 , MSPM0G3106 , MSPM0G3106-Q1 , MSPM0G3107 , MSPM0G3107-Q1 , MSPM0G3506 , MSPM0G3506-Q1 , MSPM0G3507 , MSPM0G3507-Q1 , MSPM0G3518 , MSPM0G3518-Q1 , MSPM0G3519 , MSPM0G3519-Q1

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1Introduction
    1. 1.1 Bridge between CAN and SPI
  5. 2Implementation
    1. 2.1 Principle
    2. 2.2 Structure
  6. 3Software Description
    1. 3.1 Software Functionality
    2. 3.2 Configurable Parameters
    3. 3.3 Structure of Custom Element
    4. 3.4 Structure of FIFO
    5. 3.5 SPI Receive and Transmit (Transparent Transmission)
    6. 3.6 SPI Receive and Transmit (Protocol Transmission)
    7. 3.7 CAN Receive and Transmit
    8. 3.8 Application Integration
  7. 4Hardware
  8. 5Application Aspects
    1. 5.1 Flexible structure
    2. 5.2 Optional Configuration for SPI
    3. 5.3 Optional Configuration for CAN
    4. 5.4 CAN Bus Multinode Communication Example
  9. 6Summary
  10. 7References

Principle

In this document, the CAN-SPI bridge uses both the CAN receive and transmit and the SPI receive and transmit. So both the CAN module and the SPI module must be configured. Since the message formats of different communications are different, the CAN-SPI bridge also must convert the message format.

For CAN, the CAN module supports both classic CAN and CAN FD (CAN with flexible data-rate) protocols. The CAN module is compliant with ISO 11898-1:2015. For more information, see related documentation. For the SPI, the interface can be used transfer data between a MSPM0 device and another device with serial asynchronous communication protocols. For more information, see related documentation. Since the receiving and transmitting of the SPI slave are controlled by the SPI master, the SPI slave cannot initiate transmission to the SPI master. To achieve communication from the slave to the master, a line is added to this design. The IO pull-down of the slave notifies the master that there is information that must be sent.

Figure 2-1 shows the basic principle of the CAN-SPI bridge. Typically, the communication rate of CAN is different from that of the SPI. For the CAN FD, the baud rate can be up to 5Mbps, while the SPI operates at 500k bit rate as shown in the example code. As a result, it is possible that the data received by one interface is not sent by another interface in time. To match the rate, this scheme uses a buffer to transfer data between the CAN and the SPI. This buffer not only implements data caching, but also implements data format conversion. This is equivalent to adding a barrier between the two communication interfaces. Users can add overload control actions for the overload case.

 Basic Principle of the CAN-SPI
                    Bridge Figure 2-1 Basic Principle of the CAN-SPI Bridge