S32K344 SPI with scatter/gather DMA

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

S32K344 SPI with scatter/gather DMA

1,735 次查看
sstelmak
Contributor II

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 项奖励
回复
9 回复数

1,665 次查看
sstelmak
Contributor II

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 项奖励
回复

1,642 次查看
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 项奖励
回复

1,633 次查看
sstelmak
Contributor II

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 项奖励
回复

1,605 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

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

0 项奖励
回复

1,599 次查看
sstelmak
Contributor II

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 项奖励
回复

1,581 次查看
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 项奖励
回复

1,704 次查看
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 项奖励
回复

1,699 次查看
sstelmak
Contributor II

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 项奖励
回复

1,669 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

OK. What is the behavior you are facing?

0 项奖励
回复