How to configure multiple chip selects in LPSPI module of S32K144?

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

How to configure multiple chip selects in LPSPI module of S32K144?

1,608 Views
pritampatil
Contributor III

Here i am able to transmit data via LPSPI1 if i have one chip select. But, the problem arises when i try to configure multiple chip select pins one after the other.

I have attached sample code where i have configured multiple chip selects in LPSPI1

Module: LPSPI1

PCS pins: PTA6, PTD3, PTB17

SCLK pin: PTB14

MOSI pin: PTB16

MISO pin: PTB15

I have tried the following methods.

1. Change the PCS selection SFR in LPSPI initialisation function,

i.e. LPSPI1->TCR   = 0x5100000F;

2. Configure PCS pins as GPIO and pull one pin LOW at a time and others HIGH.

please refer attached code and do the needful changes in it to make multiple slaves work.

0 Kudos
2 Replies

1,310 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

Please try something like this:

SELECT_U2();
TRANSMIT_SPI_CMDS();
while((LPSPI1->SR & LPSPI_SR_TCF_MASK)>>LPSPI_SR_TCF_SHIFT==0);
LPSPI1->SR |= LPSPI_SR_TCF_MASK;
LPSPI1_receive_16bits();

SELECT_U3();
TRANSMIT_SPI_CMDS();
while((LPSPI1->SR & LPSPI_SR_TCF_MASK)>>LPSPI_SR_TCF_SHIFT==0);
LPSPI1->SR |= LPSPI_SR_TCF_MASK;
LPSPI1_receive_16bits();

SELECT_U7();
TRANSMIT_SPI_CMDS();
while((LPSPI1->SR & LPSPI_SR_TCF_MASK)>>LPSPI_SR_TCF_SHIFT==0);
LPSPI1->SR |= LPSPI_SR_TCF_MASK;

Otherwise the code that toggles the GPIO doesn't wait for the SPI to complete the transfer.

Regards,

Daniel 

1,310 Views
pritampatil
Contributor III

Thanks... :smileyhappy:

0 Kudos