S32K344 SPI with scatter/gather DMA

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

S32K344 SPI with scatter/gather DMA

3,591 Views
sstelmak
Contributor III

I try to setup SPI to transmit/receive 8 bytes of data with one CS, and perform 4 of such transfers in sequence as quick as possible. S/W should only need to setup rx/tx buffers uint8[32] and call a non-blocking function to start entire communication. Sending/receiving of 32 bytes and generating 4 CS signals expected from the H/W.

It appears that I want to use dma scatter/gather with minor loop of 8 and major loop at 4. (Wonder if that is the best way?) But setup of Lpspi and Dma-Ip components are not very intuitive and I can't get needed functionality.

Perhaps any example or a similar setup exists to study?

 

0 Kudos
Reply
9 Replies

3,521 Views
sstelmak
Contributor III

I don't see any SPI activities, CS and CLK are at passive level.

Ports setup should be OK because earlier I saw proper communication, when I tried SPI configuration for sending a single byte without DMA.

0 Kudos
Reply

3,498 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

If you define callback to Lpspi_Ip_AsyncTransmit call, do your code get to that point?

Also I haven't seen whether you have defined callback in DMA configuration. Maybe it would be better to share screenshots from S32DS screens.

0 Kudos
Reply

3,489 Views
sstelmak
Contributor III

I didn't define a callback for transmit. I much prefer to avoid it, if it is possible

Config setup and code is in SPI_DMA_Setup1.xlsx

Note: Lpspi_Ip_AsyncTransmit() does not do anything to SPI (first call returns SUCCESS, further returns BUSY)

I tried Dma_Ip_SetLogicChannelCommand(DMA_LOGIC_CH_0, DMA_IP_CH_SET_SOFTWARE_REQUEST)

That call causes CS go active and one byte of data shifted out. Other bytes are not coming out and CS stays active forever.

 

0 Kudos
Reply

3,461 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

You don't have checked 'Enable DMAMUX Source' and 'Enable DMA Request' in both DMA Logic channel configurations.

0 Kudos
Reply

3,455 Views
sstelmak
Contributor III

Thank you, that works a little better (I can see 32 bytes transmitted) but unfortunately not quite as needed.

Lpspi_Ip_AsyncTransmit only works once, getting 32 bytes out, other calls return FAIL and no SPI activity

CS goes active as expected but never goes back to passive level (when SpiCsContinous=TRUE)

I tried SpiCsContinous=FALSE, then CS goes active/passive for each byte. That is not right, I need to send 32 bytes with one CS

It appears that SpiCsContinous=TRUE is a correct configuration.

It also appear that one minor loop is executed once and not completed successfully (since CS stays active) and it never gets to major loop.

0 Kudos
Reply

3,437 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

You need to add Interrupt Callback, pay attention here:

https://community.nxp.com/t5/S32K/LPSPI-Chip-Select-always-is-LOW-active-state/m-p/1563159

 

0 Kudos
Reply

3,560 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

SW pointers to transmit/receiver buffer are somehow different between 4 data batches or why you need to use scatter/gather? According to you description I don't see a reason for this.


Minor Loop count = 8 and Major loop Count = 4 seems to be right option for such transfer.

0 Kudos
Reply

3,555 Views
sstelmak
Contributor III

Hello,

That is correct, both tx and rx buffers are contiguous.

I tried "transfer config" option for dma, see SPI_DMA_Setup attachment for setup. 

No luck so far, what can be wrong in that setup? Thank you

0 Kudos
Reply

3,525 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

OK. What is the behavior you are facing?

0 Kudos
Reply