MPC5744P DSPI Master Mode using DMA in S32DS using Processor Expert.

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

MPC5744P DSPI Master Mode using DMA in S32DS using Processor Expert.

Jump to solution
1,458 Views
pierre_theron
Contributor III

Is it at all possible to do blocking transfers when using the DSPI in Master mode with DMA? When I use the function: DSPI_MasterTransferBlocking() the software does not get out of the OSIF_SemaWait() function and never returns. The SPI was working when it was configured for using interrupts, but I want to change it to DMA to reduce CPU overhead. It is configured in Processor expert with RX DMA channel set to 16, TX DMA channel set to 17, TX additional DMA channel set to 31, also with the callback function defined as it was when I was using interrupts. Channels 16,17 and 31 are defined in the dmaController. I also initialize the DMA with the EDMA_DRV_Init() function.

I am using another DSPI peripheral in slave mode with DMA and it is working correct, the receive callback function triggers when the data is available after calling the DSPI_SlaveTransfer() function. Also using a UART with DMA and it is also working correct.

Is there something else I need to set?

Regards

Pierre

0 Kudos
1 Solution
1,285 Views
pierre_theron
Contributor III

Hi Lukas

I changed the DMA channels to what you have and now it also works on my side. Changed the Tx additional DMA channel from channel 6 to channel 18. I am not sure if this was the cause of DMA not working as there was also other changes done to the software, but they were not DMA related. At least it works now and all is good.

Thanks a lot for your help.

Regards,

Pierre

View solution in original post

0 Kudos
5 Replies
1,286 Views
pierre_theron
Contributor III

Hi Lukas

I changed the DMA channels to what you have and now it also works on my side. Changed the Tx additional DMA channel from channel 6 to channel 18. I am not sure if this was the cause of DMA not working as there was also other changes done to the software, but they were not DMA related. At least it works now and all is good.

Thanks a lot for your help.

Regards,

Pierre

0 Kudos
1,285 Views
pierre_theron
Contributor III

Hi Lukas

I need to configure a device with commands that are only 2 bytes long during initialization. That is the only place where I use blocking functions as the commands are sent directly after each other. During normal operation I use the non blocking DSPI_MasterTransfer. If I put a breakpoint in the DSPI_DRV_MasterCompleteDMATransfer, the software never reach this breakpoint. At this moment DMA does not work at all for DSPI Master mode. Am I missing something? It was very simple to set it up a DSPI for slave mode with DMA, I did exactly the same for master mode, but it is not working. The DSPI was working when using interrupts. Then I changed the transfer type from Interrupts to DMA in Processor expert, select channels 16 for RX DMA channel, channel 17 for TX DMA channel, channel 6 for TX additional DMA channel. Added channels 6,16 and 17 to the DMA controller in Processor Expert. I can not find any example where DSPI is used in master mode that is set up with Processor Expert. Do you perhaps have such an example? To me everything looks right, but when I do the DSPI_MasterTransfer(), the callback that I defined in Processor expert is never triggered.

Regards,

Pierre

0 Kudos
1,285 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi Pierre,

it works on my side. What I did:

SPI configuration:

pastedImage_1.png

DMA configuration:

pastedImage_2.png

And I had to call:

EDMA_DRV_Init(&dmaController1_State, &dmaController1_InitConfig0, edmaChnStateArray, edmaChnConfigArray, EDMA_CONFIGURED_CHANNELS_COUNT);

That's all I configured and I can see that both DSPI_MasterTransfer and DSPI_MasterTransferBlocking are working (I used external loopback, so I received what I sent) and callback function is called when the transfer is completed.

Regards,

Lukas

0 Kudos
1,285 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

I will allocate some time next week to test it on my side. I will let you know.

Regards,

Lukas

0 Kudos
1,285 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi Pierre,

I can see in the source code that DMA is supported for blocking mode too.

DSPI_MasterTransferBlocking calls DSPI_MasterTransfer, so there's no difference. It just uses semaphores to check if the transfer is completed (in OSIF_SemaWait).

Callback function from DMA DSPI_DRV_MasterCompleteDMATransfer calls DSPI_UpdateTransferDoneState which releases the semaphore. So, it should work.

Anyway, if you use blocking function, there's no difference if interrupt or DMA is used. DMA can be useful for normal non-blocking function. Here you could see some difference. But I don't understand why you want to use DMA for blocking function.

Regards.

Lukas

0 Kudos