LPSPI for Slave Mode Communication

cancel
Showing results for 
Search instead for 
Did you mean: 

LPSPI for Slave Mode Communication

1,214 Views
bharathkumarm
Contributor I

Hi Support Team,

In one of the project S32K144 is slave device. There will be a big chunk of data transfer between master and S32K slave.(64 Bytes of data in one chip select assertion ) and this will be a period frame for every 10ms.

I want you suggestion which method is optimal for this communication.? Interrupt of DMA ?

First i want to try interrupt method. (DMA is new for me)

Configuration for this as per my understanding.

  • Set module in slave mode
  • Set chip select polarity
  • TX and RX FIFO water mark
  • Chip select, clock polarity, clock phase, prescaler, Msb first, frame size(32bit)
  • Enable interrupt for receive data RDIE. (No TX interrupt)
  • Enable LPSPI module.

As per datasheet,

Point 1. Slave Mode: Before the LPSPI_PCS input asserts, the transmit FIFO must be filled with
transmit data, or the transmit error flag will set? I did not understand this point. I am implementing my own code, but I referred SDK code, i do not see above point(Point 1) taken care in SDK.

I need your input regarding this point.

Point 2. Slave Mode: AUTOPCS bit config register 1(CFGR1), Is this bit need to be set for Slave mode ? 

I need your inputs for above two points and please correct me if am missing anything in configuration.

Labels (1)
0 Kudos
2 Replies

636 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,
This is up to you whether you use interrupts or DMA.
You can refer to SDK examples: lpspi_transfer_s32k144 & lpspi_dma_s32k144

The lpspi_tranfer uses interrupts.
If you halt the example after the slave transfer function, you can see all the registers configuration of the slave (LPSPI1).
At:

pastedImage_1.png

Also, in the example, the slave data are prepared before the MasterTrasferBlocking function is called.

pastedImage_2.png

No, the AUTOPCS bit doesn’t need to be set.

Regards,

Daniel

0 Kudos

636 Views
bharathkumarm
Contributor I

Hi Daniel,

Thanks for you response.

For me LPSPI as slave is not working. Meaning RX interrupt is not working.

I tried to Poll RDF flag but no use.

I checked Spi lines from master to LPSPI slave on CRO. I am able to observe CS, CLK and Data.  

Please find the attached code and debugger snap shot for configuration.

Please help me understanding what i am missing in configuration.

.Capture1.JPG

Note. Verified Port pins for alternate function configuration.

0 Kudos