2024-10-27 04:24 AM
Hi!
I would like to know if there is a way to handle "automaticaly" a transmit then receive transfert using SPI and DMA ?
I think using linked list should be possible, but i don't know how to configure that..
-Create a single linked list (only 1 GPDMA channel)
-Configure a 1st node with request from SPI1_TX, the tx buffer and len and add it to the linked list
-Configure a 2nd node with request from SPI1_RX, the rx buffer and len and add it to the linked list
-Call HAL_SPI_TransmitReceive_DMA
do you think it should works ?
The goal is multiple.. only 1 GPDMA channel used, manage automatically Transmit then Receive for 1 transfert..
I have same needs for 2 QuadSPI drivers.
thank for help.
2024-10-28 03:50 AM
Hello @Rickou73 ,
To configure SPI with GPDMA, I recommend you to start with available SPIs examples like these:
- SPI_FullDuplex_ComDMA_Master
Also, I advise you to take a look at this FAQ may help you "How to configure the GPDMA - STMicroelectronics Community"
I hope this help you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-10-28 04:06 AM
hi @KDJEM.1
thank you but I already know these examples..
In my case, I'm targeting a device that is not full duplex.
In this specific setup, i need in a same chip select transfer to 1st transmit some bytes, then receive some bytes.
So, I asks if it's possible to:
Using a Single (or 2) DMA channel with linked list and HAL to do both "half transfert" in a single transaction without code interaction ?
actual pseudo-code:
txbuffer[4]={......};
rxbuffer[128];
ChipSelect_Enable();
HAL_SPI_Transmit_DMA(dmaCh1, txbuffer,4);
WaitForDMAComplete(dmaCh1);
HAL_SPI_Receive_DMA(dmaCh2,rxbuffer,128);
WaitForDMAComplete(dmaCh2);
ChipSelect_Disable();
Thinking pseudo-code:
txbuffer[4]={......};
rxbuffer[128];
ChipSelect_Enable();
HAL_SPI_Transmit_Receive_DMA(dmaCh1,txbuffer,4,rxbuffer,128); // In half duplex !
WaitForDMAComplete(dmaCh1);
ChipSelect_Disable();
2024-10-29 05:46 AM
Hello @Rickou73 ,
Thank you for updating post.
Do you want to use half-duplex to run a Half-Duplex communication or simplex communication?
In these cases, the SS works as a standard ‘chip select’ input and lets the slave communicate with the master in slave mode. In Master mode, the SS can be used either as an output or an input.
In a configuration with two or more independent slaves, the master uses a star topology with dedicated GPIO pins to manage the chip select lines for each slave separately.
As mentioned in RM0456 section 17.4.5 GPDMA linked-list data structure "The direct programming mode, a channel can be programmed by a list of transfers, known as a list of linked-list items (LLI). Each LLI is defined by its data structure. " So, I didn't any limitation to one channel with a list of transfer.
So, if you used two nodes, the first node in the loop is where the LLR from the last node in the queue is pointed as mentioned in this FAQ "How to configure the linked list mode in STM32CubeMX".
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-10-29 07:23 AM
Hi @KDJEM.1
none of both ...
in fact it is a full duplex electrically,
but protocol is same as a SPI RAM/EEPROM
1st part of transaction, host send the wanted address, then 2nd part host read datas from device.
I thnink linked list can do the job, but in SPI init configuration there is 2 handlers for 2 DMA channels.. 1 for Tx, the other for Rx, so in this configuration, i can't use linked list..
and linked to that, which function should i call ?
i don't find this kind of example.
but this is the goal of this post, maybe it is not possible to do Tx, then Rx, using 1 DMA channel on SPI without code interaction during the full transaction..
For example, the octospi allow to do this.. only 1 DMA handler for both command Tx, then data Rx...