S32K344 - LPSPI and DMA configuration

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

S32K344 - LPSPI and DMA configuration

Jump to solution
2,538 Views
il_ciancio
Contributor IV

Hello to all NXP experts!

I am starting to develop an SPI communication in loopback on my EVK.

Is there any example with SPI configured with  DMA for Tx and Rx (for both Master and Slave)?

 

Thanks a lot!

Tags (1)
1 Solution
2,287 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @il_ciancio 

I wanted to clarify my previous comment. My focus was on the implementation of your code. As you mentioned, the frame size can indeed be assigned up to 64.

I apologize if my earlier message was not clear. Thank you for bringing this up.

Regarding your second question, as you correctly noted, the Length parameter of the Lpspi_Ip_AsyncTransmit() function is used for both transmission and reception. Therefore, if you send less data than expected to be received, the master or the slave will remain in a waiting state until all the expected data is received.

View solution in original post

10 Replies
2,472 Views
il_ciancio
Contributor IV

Hi @VaneB,

I have done a little step, attached you will find a configuration were (I will update also for the other users):

  • LSPI2 is master with DMA;
  • LSPI0 is slave with DMA;
  • the description is updated with "new" wired connection.

Now I am able to trasmit and receive data between the channels with the API Lpspi_Ip_AsyncTransmit.

The first trasmission works correctly, when a I try to send again data, I will not see that the buffers are updated.

Debugging, I am reaching the DMA RX interrupt, but the RAW data are not "updated".

 

Any idea?

Thanks.

0 Kudos
Reply
2,464 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @il_ciancio 

I have tested your code and have some observations. First, the S32K3 SPI Driver Integration Manual states that in DMA transfer mode, DMA transfers may cause cache coherency problems. To avoid possible coherency issues when D-CACHE is enabled, ensure that the buffers used as TCD source and destination are allocated in the NON-CACHEABLE area (using Spi_Memmap).

Regarding the buffer update problem, please test the following example code and let me know if you observe the same behavior. Note that this application uses the LPSPI driver to transfer data between LPSPI2 (master, no DMA) and LPSPI0 (slave, with DMA). Although both are not using DMA, this will help us verify the behavior.

NOTE: The example code was developed using RTD 5.0.0 and S32DS 3.5. We always recommend using the latest software and tool versions.

2,364 Views
il_ciancio
Contributor IV

Hello @VaneB,

sorry for the late reply.

I have updated as you suggested my RTD, and I have imported  

  • Lpspi_Ip_Transfer_S32K344.zip.

I have specialized a little bit your code and with the Lpspi_Ip_SyncTransmit I am able to send again data.

Regarding:

I have tested your code and have some observations. First, the S32K3 SPI Driver Integration Manual states that in DMA transfer mode, DMA transfers may cause cache coherency problems. To avoid possible coherency issues when D-CACHE is enabled, ensure that the buffers used as TCD source and destination are allocated in the NON-CACHEABLE area (using Spi_Memmap).

I have added SPI_START_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE pragma between my buffers, but something changes.

Attached you will find the project. I have configured DMA for both LSPI channel, and I am working in interrupt mode for both channel. I am using Lpspi_Ip_AsyncTransmit because of DMA.

The first exchange between Master and Slave works correctly only for the SLAVE, the MASTER hasn't received correctly all the data.

il_ciancio_0-1746438679600.png

il_ciancio_1-1746438946372.png

.

After I clean the buffers, I am sending new data, but I have the same behaviours: the rx master buffer doesn't cotain all data. As I increase the data of the buffer as the lost data is increased.

Any idea?

Thanks a lot!

 

 

 

 

 

  •  
0 Kudos
Reply
2,349 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @il_ciancio 

I believe there is a misunderstanding regarding the frame size you are assigning when calling the Lpspi_Ip_UpdateFrameSize() function. This value corresponds to each data length, not the number of data items you are transmitting. According to the TxBuffers FrameSize parameter, the function Lpspi_Ip_UpdateFrameSize() should be set to 8 instead of the 32 you are currently assigning.

Regarding your code, since the issue seems to be only from the master, I made a test by disconnecting the Slave pins and connecting the Master pins in a hardware loopback configuration (Master output connected to Master input). Please test this modified project on your side.

0 Kudos
Reply
2,323 Views
il_ciancio
Contributor IV

Hi @VaneB,

thanks to your suggestions I have done multiple messages exchange between LSPI0 and LSPI2, full duplex and with DMA, so thanks a lot, great job!

I have a question about:

According to the TxBuffers FrameSize parameter, the functionLpspi_Ip_UpdateFrameSize()should be set to 8 instead of the 32 you are currently assigning.

1) why can not I use 32 as frame size? Looking the configuration the max value could be 64 (now it is 64, I want to show you what i mean).

il_ciancio_0-1746533987119.png.

 

2)The API Lpspi_Ip_AsyncTransmit has as parameter Length "number of bytes to be sent", but It seems that It is used also as Rx side, not only for Tx side.

I have done an excercise where Master sends 1024 and receives 8, slave sends 8 and receives 1024, during the execution, the Master is always in BUSY status.

Any opinion on that?

il_ciancio_1-1746534304535.png

3) Why is there not an API/Driver only for receive (as slave) and only for send data (as master)?

It is attached also my project, maybe should be usefull for other users (RTD 5.0.0, S32D 3.5). In the project there are also the defines to test question 2.

 

Thanks!

 

0 Kudos
Reply
2,288 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @il_ciancio 

I wanted to clarify my previous comment. My focus was on the implementation of your code. As you mentioned, the frame size can indeed be assigned up to 64.

I apologize if my earlier message was not clear. Thank you for bringing this up.

Regarding your second question, as you correctly noted, the Length parameter of the Lpspi_Ip_AsyncTransmit() function is used for both transmission and reception. Therefore, if you send less data than expected to be received, the master or the slave will remain in a waiting state until all the expected data is received.

2,259 Views
il_ciancio
Contributor IV

Thanks for the support,

I will close this topic. For the third question I think the answer is the Half Duplex mode, where we can specify the sender and the receiver.

 

Thanks a lot!

0 Kudos
Reply
2,502 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @il_ciancio 

There is not a specific example code for SPI master and slave using both DMA, but the following examples might be useful:

 

BR, VaneB

0 Kudos
Reply
2,484 Views
il_ciancio
Contributor IV

Hi @VaneB,

attached you will find my project:

  • I have connected LPSPI0 (slave) and LPSPI2 (master);
  • LPSPI2 is working with DMA;
  • LPSPI0 is working without DMA;

running the code, I see that the data sent by LPSPI2 is received by LPSPI0, but the data sent by LPSPI0 is NOT received by LPSPI2.

Moreover, If I try to sent again data the code goes to in an HardFaultHandler.

Do you have any idea?

0 Kudos
Reply
2,483 Views
il_ciancio
Contributor IV
The hard faul handler was raised becaus of a typo error on line 220 of main.c:
Lpspi_Ip_AsyncTransmit(&MASTER_EXTERNAL_DEVICE, TxMasterBuffer, RxMasterBuffer, NUMBER_OF_BYTES, TIMEOUT);

I have changed TIMEOUT with a callback, but the data are not exchanged between the LSPI.

Thanks and sorry for the error.
0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2089294%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32K344%20-%20LPSPI%20and%20DMA%20configuration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2089294%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20to%20all%20NXP%20experts!%3C%2FP%3E%3CP%3EI%20am%20starting%20to%20develop%20an%20SPI%20communication%20in%20loopback%20on%20my%20EVK.%3C%2FP%3E%3CP%3EIs%20there%20any%20example%20with%20SPI%20configured%20with%26nbsp%3B%20DMA%20for%20Tx%20and%20Rx%20(for%20both%20Master%20and%20Slave)%3F%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EThanks%20a%20lot!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2093424%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K344%20-%20LPSPI%20and%20DMA%20configuration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2093424%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThanks%20for%20the%20support%2C%3C%2FP%3E%3CP%3EI%20will%20close%20this%20topic.%20For%20the%20third%20question%20I%20think%20the%20answer%20is%20the%20Half%20Duplex%20mode%2C%20where%20we%20can%20specify%20the%20sender%20and%20the%20receiver.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EThanks%20a%20lot!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2093109%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K344%20-%20LPSPI%20and%20DMA%20configuration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2093109%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F248332%22%20target%3D%22_blank%22%3E%40il_ciancio%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20wanted%20to%20clarify%20my%20previous%20comment.%20My%20focus%20was%20on%20the%20implementation%20of%20your%20code.%20As%20you%20mentioned%2C%20the%20frame%20size%20can%20indeed%20be%20assigned%20up%20to%2064.%3C%2FP%3E%0A%3CP%3EI%20apologize%20if%20my%20earlier%20message%20was%20not%20clear.%20Thank%20you%20for%20bringing%20this%20up.%3C%2FP%3E%0A%3CP%3ERegarding%20your%20second%20question%2C%20as%20you%20correctly%20noted%2C%20the%20Length%20parameter%20of%20the%20Lpspi_Ip_AsyncTransmit()%20function%20is%20used%20for%20both%20transmission%20and%20reception.%20Therefore%2C%20if%20you%20send%20less%20data%20than%20expected%20to%20be%20received%2C%20the%20master%20or%20the%20slave%20will%20remain%20in%20a%20waiting%20state%20until%20all%20the%20expected%20data%20is%20received.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2092184%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K344%20-%20LPSPI%20and%20DMA%20configuration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2092184%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F201913%22%20target%3D%22_blank%22%3E%40VaneB%3C%2FA%3E%2C%3C%2FP%3E%3CP%3Ethanks%20to%20your%20suggestions%20I%20have%20done%20multiple%20messages%20exchange%20between%20LSPI0%20and%20LSPI2%2C%20full%20duplex%20and%20with%20DMA%2C%20so%20thanks%20a%20lot%2C%20great%20job!%3C%2FP%3E%3CP%3EI%20have%20a%20question%20about%3A%3C%2FP%3E%3CBLOCKQUOTE%3E%3CP%3E%3CSPAN%3EAccording%20to%20the%20TxBuffers%20FrameSize%20parameter%2C%20the%20function%3C%2FSPAN%3E%3CEM%3ELpspi_Ip_UpdateFrameSize()%3C%2FEM%3E%3CSPAN%3Eshould%20be%20set%20to%208%20instead%20of%20the%2032%20you%20are%20currently%20assigning.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FBLOCKQUOTE%3E%3CP%3E%3CSPAN%3E1)%20why%20can%20not%20I%20use%2032%20as%20frame%20size%3F%20Looking%20the%20configuration%20the%20max%20value%20could%20be%2064%20(now%20it%20is%2064%2C%20I%20want%20to%20show%20you%20what%20i%20mean).%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22il_ciancio_0-1746533987119.png%22%20style%3D%22width%3A%20625px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22il_ciancio_0-1746533987119.png%22%20style%3D%22width%3A%20625px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336359iD03B1B33B6F34FDE%2Fimage-dimensions%2F625x326%3Fv%3Dv2%22%20width%3D%22625%22%20height%3D%22326%22%20role%3D%22button%22%20title%3D%22il_ciancio_0-1746533987119.png%22%20alt%3D%22il_ciancio_0-1746533987119.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E2)The%20API%20Lpspi_Ip_AsyncTransmit%20has%20as%20parameter%20Length%20%22number%20of%20bytes%20to%20be%20sent%22%2C%20but%20It%20seems%20that%20It%20is%20used%20also%20as%20Rx%20side%2C%20not%20only%20for%20Tx%20side.%3C%2FP%3E%3CP%3EI%20have%20done%20an%20excercise%20where%20Master%20sends%201024%20and%20receives%208%2C%20slave%20sends%208%20and%20receives%201024%2C%20during%20the%20execution%2C%20the%20Master%20is%20always%20in%20BUSY%20status.%3C%2FP%3E%3CP%3EAny%20opinion%20on%20that%3F%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22il_ciancio_1-1746534304535.png%22%20style%3D%22width%3A%20497px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22il_ciancio_1-1746534304535.png%22%20style%3D%22width%3A%20497px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336362i255E6DC46D10CB1F%2Fimage-dimensions%2F497x269%3Fv%3Dv2%22%20width%3D%22497%22%20height%3D%22269%22%20role%3D%22button%22%20title%3D%22il_ciancio_1-1746534304535.png%22%20alt%3D%22il_ciancio_1-1746534304535.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E3)%20Why%20is%20there%20not%20an%20API%2FDriver%20only%20for%20receive%20(as%20slave)%20and%20only%20for%20send%20data%20(as%20master)%3F%3C%2FP%3E%3CP%3EIt%20is%20attached%20also%20my%20project%2C%20maybe%20should%20be%20usefull%20for%20other%20users%20(RTD%205.0.0%2C%20S32D%203.5).%20In%20the%20project%20there%20are%20also%20the%20defines%20to%20test%20question%202.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EThanks!%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2091671%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K344%20-%20LPSPI%20and%20DMA%20configuration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2091671%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F248332%22%20target%3D%22_blank%22%3E%40il_ciancio%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20believe%20there%20is%20a%20misunderstanding%20regarding%20the%20frame%20size%20you%20are%20assigning%20when%20calling%20the%20%3CEM%3ELpspi_Ip_UpdateFrameSize()%3C%2FEM%3E%20function.%20This%20value%20corresponds%20to%20each%20data%20length%2C%20not%20the%20number%20of%20data%20items%20you%20are%20transmitting.%20According%20to%20the%20TxBuffers%20FrameSize%20parameter%2C%20the%20function%20%3CEM%3ELpspi_Ip_UpdateFrameSize()%3C%2FEM%3E%20should%20be%20set%20to%208%20instead%20of%20the%2032%20you%20are%20currently%20assigning.%3C%2FP%3E%0A%3CP%3ERegarding%20your%20code%2C%20since%20the%20issue%20seems%20to%20be%20only%20from%20the%20master%2C%20I%20made%20a%20test%20by%20disconnecting%20the%20Slave%20pins%20and%20connecting%20the%20Master%20pins%20in%20a%20hardware%20loopback%20configuration%20(Master%20output%20connected%20to%20Master%20input).%20Please%20test%20this%20modified%20project%20on%20your%20side.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2091357%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K344%20-%20LPSPI%20and%20DMA%20configuration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2091357%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CFONT%20face%3D%22arial%2Chelvetica%2Csans-serif%22%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F201913%22%20target%3D%22_blank%22%3E%40VaneB%3C%2FA%3E%2C%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22arial%2Chelvetica%2Csans-serif%22%3Esorry%20for%20the%20late%20reply.%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22arial%2Chelvetica%2Csans-serif%22%3EI%20have%20updated%20as%20you%20suggested%20my%20RTD%2C%20and%20I%20have%20imported%26nbsp%3B%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%3CUL%3E%3CLI%3E%3CFONT%20face%3D%22arial%2Chelvetica%2Csans-serif%22%3E%3CSPAN%20class%3D%22%22%3ELpspi_Ip_Transfer_S32K344.zip.%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CFONT%20face%3D%22arial%2Chelvetica%2Csans-serif%22%3E%3CSPAN%20class%3D%22%22%3EI%20have%20specialized%20a%20little%20bit%20your%20code%20and%20with%20the%20Lpspi_Ip_SyncTransmit%20I%20am%20able%20to%20send%20again%20data.%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22arial%2Chelvetica%2Csans-serif%22%3E%3CSPAN%20class%3D%22%22%3ERegarding%3A%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%3CBLOCKQUOTE%3E%3CP%3E%3CFONT%20face%3D%22arial%2Chelvetica%2Csans-serif%22%3E%3CSPAN%20class%3D%22%22%3EI%20have%20tested%20your%20code%20and%20have%20some%20observations.%20First%2C%20the%20S32K3%20SPI%20Driver%20Integration%20Manual%20states%20that%20in%20DMA%20transfer%20mode%2C%20DMA%20transfers%20may%20cause%20cache%20coherency%20problems.%20To%20avoid%20possible%20coherency%20issues%20when%20D-CACHE%20is%20enabled%2C%20ensure%20that%20the%20buffers%20used%20as%20TCD%20source%20and%20destination%20are%20allocated%20in%20the%20NON-CACHEABLE%20area%20(using%20Spi_Memmap).%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%3C%2FBLOCKQUOTE%3E%3CP%3E%3CFONT%20face%3D%22arial%2Chelvetica%2Csans-serif%22%3E%3CSPAN%20class%3D%22%22%3EI%20have%20added%26nbsp%3BSPI_START_SEC_VAR_CLEARED_UNSPECIFIED_NO_CACHEABLE%20pragma%20between%20my%20buffers%2C%20but%20something%20changes.%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3EAttached%20you%20will%20find%20the%20project.%20I%20have%20configured%20DMA%20for%20both%20LSPI%20channel%2C%20and%20I%20am%20working%20in%20interrupt%20mode%20for%20both%20channel.%20I%20am%20using%26nbsp%3BLpspi_Ip_AsyncTransmit%20because%20of%20DMA.%3C%2FP%3E%3CP%3EThe%20first%20exchange%20between%20Master%20and%20Slave%20works%20correctly%20only%20for%20the%20SLAVE%2C%20the%20MASTER%20hasn't%20received%20correctly%20all%20the%20data.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22il_ciancio_0-1746438679600.png%22%20style%3D%22width%3A%20545px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22il_ciancio_0-1746438679600.png%22%20style%3D%22width%3A%20545px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336170i41648CEB7FAAC5D5%2Fimage-dimensions%2F545x305%3Fv%3Dv2%22%20width%3D%22545%22%20height%3D%22305%22%20role%3D%22button%22%20title%3D%22il_ciancio_0-1746438679600.png%22%20alt%3D%22il_ciancio_0-1746438679600.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22il_ciancio_1-1746438946372.png%22%20style%3D%22width%3A%20442px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22il_ciancio_1-1746438946372.png%22%20style%3D%22width%3A%20442px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336171iE51BE9ECC5E36E16%2Fimage-dimensions%2F442x380%3Fv%3Dv2%22%20width%3D%22442%22%20height%3D%22380%22%20role%3D%22button%22%20title%3D%22il_ciancio_1-1746438946372.png%22%20alt%3D%22il_ciancio_1-1746438946372.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E.%3C%2FP%3E%3CP%3EAfter%20I%20clean%20the%20buffers%2C%20I%20am%20sending%20new%20data%2C%20but%20I%20have%20the%20same%20behaviours%3A%20the%20rx%20master%20buffer%20doesn't%20cotain%20all%20data.%20As%20I%20increase%20the%20data%20of%20the%20buffer%20as%20the%20lost%20data%20is%20increased.%3C%2FP%3E%3CP%3EAny%20idea%3F%3C%2FP%3E%3CP%3EThanks%20a%20lot!%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CUL%3E%3CLI%3E%26nbsp%3B%3C%2FLI%3E%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2090421%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K344%20-%20LPSPI%20and%20DMA%20configuration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2090421%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F248332%22%20target%3D%22_blank%22%3E%40il_ciancio%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20have%20tested%20your%20code%20and%20have%20some%20observations.%20First%2C%20the%20S32K3%20SPI%20Driver%20Integration%20Manual%20states%20that%20in%20DMA%20transfer%20mode%2C%20DMA%20transfers%20may%20cause%20cache%20coherency%20problems.%20To%20avoid%20possible%20coherency%20issues%20when%20D-CACHE%20is%20enabled%2C%20ensure%20that%20the%20buffers%20used%20as%20TCD%20source%20and%20destination%20are%20allocated%20in%20the%20NON-CACHEABLE%20area%20(using%20Spi_Memmap).%3C%2FP%3E%0A%3CP%3ERegarding%20the%20buffer%20update%20problem%2C%20please%20test%20the%20following%20example%20code%20and%20let%20me%20know%20if%20you%20observe%20the%20same%20behavior.%20Note%20that%20this%20application%20uses%20the%20LPSPI%20driver%20to%20transfer%20data%20between%20LPSPI2%20(master%2C%20no%20DMA)%20and%20LPSPI0%20(slave%2C%20with%20DMA).%20Although%20both%20are%20not%20using%20DMA%2C%20this%20will%20help%20us%20verify%20the%20behavior.%3C%2FP%3E%0A%3CP%3ENOTE%3A%20The%20example%20code%20was%20developed%20using%20RTD%205.0.0%20and%20S32DS%203.5.%20We%20always%20recommend%20using%20the%20latest%20software%20and%20tool%20versions.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2090259%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K344%20-%20LPSPI%20and%20DMA%20configuration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2090259%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F201913%22%20target%3D%22_blank%22%3E%40VaneB%3C%2FA%3E%2C%3C%2FP%3E%3CP%3EI%20have%20done%20a%20little%20step%2C%20attached%20you%20will%20find%20a%20configuration%20were%20(I%20will%20update%20also%20for%20the%20other%20users)%3A%3C%2FP%3E%3CUL%3E%3CLI%3ELSPI2%20is%20master%20with%20DMA%3B%3C%2FLI%3E%3CLI%3ELSPI0%20is%20slave%20with%20DMA%3B%3C%2FLI%3E%3CLI%3Ethe%20description%20is%20updated%20with%20%22new%22%20wired%20connection.%3C%2FLI%3E%3C%2FUL%3E%3CP%3ENow%20I%20am%20able%20to%20trasmit%20and%20receive%20data%20between%20the%20channels%20with%20the%20API%26nbsp%3BLpspi_Ip_AsyncTransmit.%3C%2FP%3E%3CP%3EThe%20first%20trasmission%20works%20correctly%2C%20when%20a%20I%20try%20to%20send%20again%20data%2C%20I%20will%20not%20see%20that%20the%20buffers%20are%20updated.%3C%2FP%3E%3CP%3EDebugging%2C%20I%20am%20reaching%20the%20DMA%20RX%20interrupt%2C%20but%20the%20RAW%20data%20are%20not%20%22updated%22.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EAny%20idea%3F%3C%2FP%3E%3CP%3EThanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2090026%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K344%20-%20LPSPI%20and%20DMA%20configuration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2090026%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EThe%20hard%20faul%20handler%20was%20raised%20becaus%20of%20a%20typo%20error%20on%20line%20220%20of%20main.c%3A%3CBR%20%2F%3ELpspi_Ip_AsyncTransmit(%26amp%3BMASTER_EXTERNAL_DEVICE%2C%20TxMasterBuffer%2C%20RxMasterBuffer%2C%20NUMBER_OF_BYTES%2C%20TIMEOUT)%3B%3CBR%20%2F%3E%3CBR%20%2F%3EI%20have%20changed%20TIMEOUT%20with%20a%20callback%2C%20but%20the%20data%20are%20not%20exchanged%20between%20the%20LSPI.%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20and%20sorry%20for%20the%20error.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2089986%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K344%20-%20LPSPI%20and%20DMA%20configuration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2089986%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F201913%22%20target%3D%22_blank%22%3E%40VaneB%3C%2FA%3E%2C%3C%2FP%3E%3CP%3Eattached%20you%20will%20find%20my%20project%3A%3C%2FP%3E%3CUL%3E%3CLI%3EI%20have%20connected%20LPSPI0%20(slave)%20and%20LPSPI2%20(master)%3B%3C%2FLI%3E%3CLI%3ELPSPI2%20is%20working%20with%20DMA%3B%3C%2FLI%3E%3CLI%3ELPSPI0%20is%20working%20without%20DMA%3B%3C%2FLI%3E%3C%2FUL%3E%3CP%3Erunning%20the%20code%2C%20I%20see%20that%20the%20data%20sent%20by%26nbsp%3BLPSPI2%20is%20received%20by%20LPSPI0%2C%20but%20the%20data%20sent%20by%26nbsp%3BLPSPI0%20is%20NOT%20received%20by%26nbsp%3BLPSPI2.%3C%2FP%3E%3CP%3EMoreover%2C%20If%20I%20try%20to%20sent%20again%20data%20the%20code%20goes%20to%20in%20an%20HardFaultHandler.%3C%2FP%3E%3CP%3EDo%20you%20have%20any%20idea%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2089551%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K344%20-%20LPSPI%20and%20DMA%20configuration%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2089551%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F248332%22%20target%3D%22_blank%22%3E%40il_ciancio%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20is%20not%20a%20specific%20example%20code%20for%20SPI%20master%20and%20slave%20using%20both%20DMA%2C%20but%20the%20following%20examples%20might%20be%20useful%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K-Knowledge-Base%2FExample-S32K344-SPI-Transmit-amp-Receive-Using-DMA-DS3-5-RTD500%2Fta-p%2F1992224%22%20target%3D%22_blank%22%3EExample%20S32K344%20SPI%20Transmit%20%26amp%3B%20Receive%20Using%20DMA%20DS3.5%20RTD500%3C%2FA%3E%3A%20This%20application%20uses%20the%20LPSPI%20driver%20to%20transfer%20data%20between%20LPSPI2%20(master%2C%20no%20DMA)%20and%20LPSPI0%20(slave%2C%20with%20DMA)%20physical%20units.%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K-Knowledge-Base%2FExample-S32K312-SPI-Transmit-amp-Receive-Using-DMA-DS3-5-RTD300%2Fta-p%2F1787856%22%20target%3D%22_blank%22%3EExample%20S32K312%20SPI%20Transmit%20%26amp%3B%20Receive%20Using%20DMA%20DS3.5%20RTD300%3C%2FA%3E%3A%20This%20application%20uses%20the%20LPSPI%20driver%20to%20transfer%20data%20with%20LPSPI2%20(master%2C%20DMA)%20in%20a%20hardware%20loopback%20configuration%20(MOSI%20connected%20to%20MISO).%3C%2FLI%3E%0A%3CLI%3EExample%20codes%20provided%20with%20the%20RTDs.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBR%2C%20VaneB%3C%2FP%3E%3C%2FLINGO-BODY%3E