LPSPI Chip Select always is LOW (active state)

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

LPSPI Chip Select always is LOW (active state)

Jump to solution
3,392 Views
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 Kudos
Reply
1 Solution
3,213 Views
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.

View solution in original post

0 Kudos
Reply
13 Replies
3,347 Views
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 Kudos
Reply
3,340 Views
MVR
Contributor IV

@davidtosenovjan have you ever seen this problem?

0 Kudos
Reply
3,335 Views
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 Kudos
Reply
3,312 Views
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 Kudos
Reply
3,285 Views
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 Kudos
Reply
3,255 Views
MVR
Contributor IV

Ok David, thanks for the help!

I'm waiting for the answer.

0 Kudos
Reply
3,214 Views
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 Kudos
Reply
3,201 Views
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 Kudos
Reply
3,174 Views
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 Kudos
Reply
3,164 Views
MVR
Contributor IV
Nice David, it worked! Thanks
0 Kudos
Reply
3,377 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

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

0 Kudos
Reply
3,366 Views
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 Kudos
Reply