Home Forums Software FlexCase G (CM4 + S32K3): MPU–MCU SPI communication not receiving data

Viewing 2 reply threads
  • Author
    Posts
    • dgordondgordon
      Participant
      Post count: 1

      Hi Audesse Team,

      I have been working on the MPU–MCU SPI communication example for the FlexCase G using the Raspberry Pi CM4 and the S32K3 MCU, but I have been unable to establish communication between the two processors. The MCU model builds and flashes successfully, and the Raspberry Pi model also builds, deploys, and runs without any reported errors. However, the Raspberry Pi only receives zeros from the SPI transfer instead of the expected data.

      I have tried debugging both the Raspberry Pi and MCU configurations and have tried to eliminate as many potential causes as possible. On the Raspberry Pi side, I modified MW_SPI.c so that the support package uses /dev/spidev1.x, as described in the FlexCase documentation for the CM4. I confirmed that /dev/spidev1.0 exists on the target, and using strace I verified that the application successfully opens /dev/spidev1.0 and continuously performs SPI ioctl() transactions. The SPI1 overlay (dtoverlay=spi1-1cs) is enabled, and gpioinfo/pinctrl confirm that the SPI1 pins are configured on GPIO18–GPIO21.

      On the MCU side, I checked that that LPSPI4 is configured as the SPI slave. The generated code confirms that Spi_SetupEB() is called using a 64-byte external buffer and that Spi_AsyncTransmit() is executed every model step. I have also verified that the SPI pins are configured for the LPSPI4 peripheral within the Port Configuration Tool and that the generated configuration files appear consistent with the model.

      To rule out configuration issues, I have also tested multiple SPI modes (Mode 0 and Mode 2), rebuilt both the MPU and MCU projects, removed and regenerated the deployment folders, and confirmed that the Raspberry Pi is using the correct SPI device. Despite these tests, the Raspberry Pi continues to receive only zeros, and no SPI data appears to be exchanged.

      At this point, I am wondering what I’m doing wrong and if there is an additional configuration step that is required for the S32K3 implementation, or if there is an updated S32K3-specific MPU–MCU SPI example available. The example currently available on the website appears to have originally been developed for the S32K1 platform.

      Could you please confirm:

      Whether there is an official S32K3 MPU–MCU SPI example for the FlexCase G.
      The expected SPI configuration between the CM4 and S32K3 (SPI mode, LPSPI instance, chip select, etc.).
      Whether there are any additional initialization or driver configuration steps required on the S32K3 that are not included in the documentation.
      Whether this example has been verified using the current MATLAB R2025a support packages.

      Thank you,
      Juan

    • benmaccallum1benmaccallum1
      Moderator
      Post count: 3

      Hi Juan,

      I’m sorry that you are experiencing issues with the MCU-MPU SPI communication.

      Regarding the S32K3 configuration, SPI Mode 2 is correct. In the configuration source file, Lpspi_Ip_MBDT_PBcfg.c, verify that CPOL == 1 and CPHA == 0 for the MPU SPI instance, as shown in the attached image. There is a known bug in the existing S32K3 FlexConnect sample model which erroneously sets the MPU SPI channel to Mode 3. We are planning to release a new version (Rev 2.3) of the sample models for the FCE and FCG this week, which will resolve this bug. It will be available for download under Simulink Library & Examples here: Downloads.

      Ben

      Attachments:
      You must be logged in to view attached files.
    • benmaccallum1benmaccallum1
      Moderator
      Post count: 3

      Hi Juan, I spoke to a colleague and learned your issue has already been resolved. I’m glad it is working once again.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.