How to connect more than 4 slave devices using the same SPI instance on S32K144?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to connect more than 4 slave devices using the same SPI instance on S32K144?

3,251 Views
randylin
Contributor I

According to S32K144 datasheet, one LPSPI instance can support 4 slave devices.
In my application, 8 slave devices must share the same SPI bus.
Can I use 8 IO to manual control the chip select of each slave device?
If yes, how to configure it?

0 Kudos
Reply
7 Replies

3,233 Views
randylin
Contributor I

Hi Stano,

Thanks for these solutions.

The first option require more space and cost, not the best solution we want.
The second option use FLEXIO.
To connect 8 slave devices, need 11 pins(SPI_CLK, SPI_SOUT, SPI_SIN and 8 SPI_PCSx), but FLEXIO only have 8 pins.

Can I configure LPSPI instance without the PCS? Then I can use 8 GPIO to select slave devices.

0 Kudos
Reply

3,225 Views
StanoA
NXP TechSupport
NXP TechSupport

Hi Randy Lin,

It is possible to use one whole LPSPI module for one external SPI device with PCS0. The PCS1 signal connect to one pin of FLEXIO as input also. The rest 7 SPI external devices can be controlled by rest of FLEXIO pins. It will mux the input pin PCS1 to one of rest 7 pins which are connected to chip select pins of rest external SPI devices. Then the SPI communication protocol will be the same for all external devices and the only chip select line will define opposite site for communication.

I hope it could help you to solve your task.

Best Regards,

Stano.

0 Kudos
Reply

3,210 Views
randylin
Contributor I

Hi Stano,

Unfortunately, we add more devices to SPI bus.
I just want to make sure LPSPI instance can work correctly without configure any PCS pin,
and the chip select are controlled manually through GPIO.
Can you confirm this is a possible solution?

0 Kudos
Reply

3,203 Views
StanoA
NXP TechSupport
NXP TechSupport

Hi Randy Lin,

As I mentioned in previous message the FLEXIO module will work as “1 to 7” multiplexer. So it can add next 7 SPI devices to one SPI internal periphery. Please not the PCSx signals are not static during SPI communication. The chip selects can’t be controlled manually by GPIO. So you can use the max number of the external SPI peripherals as the sum of PCSx signals of all SPI internal modules plus 7 generated by FLEXIO.

Best Regards,

Stano.

0 Kudos
Reply

3,191 Views
randylin
Contributor I

Hi Stano,

I don't know why you said chip select can't controlled manually by GPIO.
Here is the concept of communication with one specific slave device:
Before SPI frame transmission, pull the chip select "N" low,
After the SPI frame transmission complete, set the chip select "N" high.
Am I missing something?
As I said previously, we add more slave devices to the SPI bus.
At least 15 devices(maybe more...), can't handle by "LPSPI + FLEXIO".
That's why I try to use GPIO to control chip select.

Best Regards,
Randy

0 Kudos
Reply

3,185 Views
StanoA
NXP TechSupport
NXP TechSupport

Hi Randy,

All depends on the external SPI devices category. If you use the same type and the READ instruction only the all devices can be connected to one PCSx pin and the serial DIN and DOUT pin of all devices connected in series. The you can connect e.g. 20 pcs of the external SPI devices on one SPI module with one (very strong) PCSx pin.

In case you use different types on SPI external devices you need group them to groups with compatible data format e.g. 8-bit and 16-bit and then use two SPI modules (one for 8-bit and one for 16-bit group) and READ or WRITE the serial data string of all devices.

If you use the external devices with WRITE function also the PSCx pin change the active low level during communication (e.g. SPI serial memory).

So please investigate the communication protocol of each external SPI device it will be connected and make selection to compatible groups. Also decide if you want activate all devices in the communication string or whether they will be always connected. This task has many different solution so please select the best one which fits your application.

I hope it can help you to solve your task.

Best Regards,

Stano.

0 Kudos
Reply

3,246 Views
StanoA
NXP TechSupport
NXP TechSupport

Hello Randy Lin,

The SPI peripheral has the common signals SPI_CLK, SPI_SOUT, SPI_SIN and the chip select signals PCS0, 1, 2. The chip select signals are active low during data transfer to addressed peripheral. So there are several options how to increase number of peripherals connected to one SPI module:

  • Use the simple logical multiplexer (one to eight) and control the PSCx signal to each peripheral by three GPIO pins
  • Or use the FLEXIO module for build the new SPI module with eight chip select signals.

All depends on the priority – the first option requires the external multiplexer and the second option requires the added effort to build the SW code for new SPI peripheral.

The next option is to use more than one internal SPI modules to cower all eight external SPI devices.

I hope it could help you to decide for right solution.

Best Regards,

Stano.

0 Kudos
Reply