LPSPI Chip Select always is LOW (active state)

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

LPSPI Chip Select always is LOW (active state)

跳至解决方案
3,398 次查看
MVR
Contributor IV

Hello,

The chip select is always LOW after we send out the first command, it couldn't be in LOW but must be in HIGH (deactivate state), after finish transmission (in this case, after send the 10 bytes):

MVR_0-1669950015569.png

I'm using this configuration:

MVR_1-1669950193535.png

MVR_2-1669950223890.png


I'm using DMA to TX and RX. The DMA callbacks works well.

I'm using as well this function to transfer data:

Lpspi_Ip_AsyncTransmit();

In Lpspi_Ip_UpdateTransferMode I set with LPSPI_IP_INTERRUPT.

Thanks

0 项奖励
回复
1 解答
3,219 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

I haven't noticed but RTD expert found it out. You have a mistake in your configuration.

As LPSPI instance is 0 so you should put Lpspi_Ip_LPSPI_0_IrqTxDmaHandler in DMA interrupt callback:

davidtosenovjan_0-1672750801661.png

Attached modified project.

在原帖中查看解决方案

0 项奖励
回复
13 回复数
3,353 次查看
MVR
Contributor IV

I debugged the code, when we used DMA, the chip select is always LOW (active state):

Base->TCR is never changed, in the other words, Lpspi_Ip_TxDmaFinishTransfer / Lpspi_Ip_TransferProcess are never called.
 
I initialized the SPI with this way:
MVR_0-1670004686888.png

 

Must I use these callbacks in "IntCtrl_Ip_InstallHandler"? The callback "Dma0_Ch1_IRQHandler" have never changed the Chip Select state, but this function notify that the buffer of DMA about SPI is ok and I can use it.

Another information. When I use simple ISR (the callback "Lpspi_Ip_LPSPI_0_IRQHandler"), the Chip select works according, but I would like to use DMA and not ISR. I saw also I can't use both together.

So, summarize, when I use DMA, there is this problem. The sending, receiving and notify callback of DMA are working well, but the chip select is not working.

I'm using this function to send message:

MVR_1-1670005276624.png

 

0 项奖励
回复
3,346 次查看
MVR
Contributor IV

@davidtosenovjan have you ever seen this problem?

0 项奖励
回复
3,341 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

Could you send me the whole project? I mean the whole example how you have configured it showing mentioned behavior. I will try to debug it or report to software developers if needed. Thanks

0 项奖励
回复
3,318 次查看
MVR
Contributor IV

Hello @davidtosenovjan 

Follow the zip with problem using DMA. 

We can see in this code, one example of sending 10 bytes of SPI using DMA, result:

MVR_2-1670867808321.png

MVR_4-1670867836276.png

If we test this code without DMA:

MVR_7-1670867896997.png

We get this result:

MVR_9-1670867946311.png

Thanks!

0 项奖励
回复
3,291 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

I just played with this code for quite long time but I haven't found anything wrong.

I guess there is an issue with RTD driver. I will report it and we will see. I will return to you.

0 项奖励
回复
3,261 次查看
MVR
Contributor IV

Ok David, thanks for the help!

I'm waiting for the answer.

0 项奖励
回复
3,220 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

I haven't noticed but RTD expert found it out. You have a mistake in your configuration.

As LPSPI instance is 0 so you should put Lpspi_Ip_LPSPI_0_IrqTxDmaHandler in DMA interrupt callback:

davidtosenovjan_0-1672750801661.png

Attached modified project.

0 项奖励
回复
3,207 次查看
MVR
Contributor IV

Ok, but which callback should I use as user callback? Because this "Lpspi_Ip_LPSPI_0_IrqTxDmaHandler" is not available to user, right? I would like to use this callback to do some things.

This "Lpspi_Ip_LPSPI_2_IrqTxDmaHandler" that I defined could be any name, because I'm considering it as an user callback.

Thanks.

0 项奖励
回复
3,180 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

You can put SPI_Callback to the transmit function calling where you have NULL pointer

davidtosenovjan_0-1672908311851.png

I am attaching screenshot from some example code for reference

davidtosenovjan_1-1672908473766.png

 

0 项奖励
回复
3,170 次查看
MVR
Contributor IV
Nice David, it worked! Thanks
0 项奖励
回复
3,379 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport
0 项奖励
回复
3,383 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

Could you specify used S32 Design Studio? Also please clarify which MCU you are using.

0 项奖励
回复
3,372 次查看
MVR
Contributor IV

Ops, I forgot. I'm sorry.

I'm using S32K344 and S32K3 RTD AUTOSAR 4.4 2.0.1 D2207 in S32 Design Studio.

0 项奖励
回复