STM32L151CBT6 SPI Full-Duplex as slave: Problems understanding SPI DMA and how to use it
Hello, in my setup the STM32L151CBT6 (32MHz) is configured as slave of a PLD Master, which provides a 4MHz Clk for the SPI communication.
After a short "handshake" between slave and PLD where the slave sends and receives some bytes (with HAL_SPI_Transmit and HAL_SPI_Receive in a while loop until a specific handshake value is received) for confirmation that it had a successfull "start-up" phase the master then starts sending 64Byte Data packages in a cyclic manner.
In previous tests I (with the help of the forum Einstein TDK) came to the conclusion that the HAL_SPI_TransmitReceive function is to slow. So now I want to use the HAL_SPI_TransmitReceive_DMA function. When I just use the HAL_SPI_TransmitReceive_DMA function in a while loop in my main function I see (on a digital oscilloscope) that my master and slave send the right Dummy values in correct order.
My slave should have a 400µs window between each received package to manipulate data.
To test if my slave receives the right data during the operational phase I wanted it to copy the received data and send it out in the next package cycle.
I think the problem lies in the lack of understanding how to use the HAL_SPI_TransmitReceive_DMA function properly. Maybe someone can explain how I get my test setup working and how to use the HAL_SPI_TransmitReceive_DMA function the right way (and even if I can use it for my use case)?
I posted the simple main while loop for my Test setup, which does not work. It aborts the slave sending part afer the 1st byte.
while (1)
{
HAL_SPI_TransmitReceive_DMA(&hspi1, Configuration_Values_Tx, Configuration_Values_Rsx, 64);
for (iter_i =0; iter_i < sizeof(Configuration_Values_Rsx); iter_i ++)
{
Configuration_Values_Tx[iter_i] = Configuration_Values_Rsx[iter_i];
}
}