Electronic – Low Power SPI Module communication between Microcontrollers

digital-communicationsmicrocontrollernxpserialspi

I have 2 microcontrollers – one is S32K118 and other is S32K142. Both are 64 pins. S32K1xx datasheet

I need communication between the Microcontrollers in SPI Configuration.

Suppose the microcontroller supports 2 LPSPI modules, say LPSPI0, LPSPI1, LPSPI2.

For that, I need to connect the LPSPI0 module pins from one microcontroller to the LPSPI0 module pins in the other microcontroller, right?

Or it doesn't matter if the SPI communication between one microcontroller and the another microcontroller takes places on different SPI modules, like say LPSPI0 in 1st and LPSPI1 in another microcontroller? or LPSPI1 in 1st controller and LPSPI2 in the second controller?

And what about the chip select pin?
Which module should I select for the chip select in SPI communication between the microcontrollers? Why are they 2 modules for chip select? Like, which should I choose based on which will act as the master microcontroller initiating the SPI communication and which microcontroller will act as the slave.
enter image description here

This SPI Communcation is only between the 2 microcontrollers.
Please explain to clear this confusion. Stuck here.

Any recommendations?

Best Answer

It does not matter which SPI module you use, so you can connect SPI0 of one microcontroller to SPI1 of the other. The SPI modules (like any others) are independent of each other.

The main reason there are multiple SPI's is to connect two devices (each with their own SPI controller), or to have a more flexible configuration. Mostly pins are having multiple functions, and by using SPI0, maybe UART1 does not work as they share pins, so you can use SPI1.

For the chip select pins, if you use SPI1, you should use CS1. On some microcontrollers I thought they can be any pin, but with the ones you use it seems to be hard-wired.