Skip to main content
Visitor II
April 23, 2025
Question

STM32L4 SPI Half-Duplex Master DMA help

  • April 23, 2025
  • 1 reply
  • 421 views

Hello friends

I don't know what to do and I'm going to ask for help, in my project I use SPI and Full-Duplex mode with the following configuration which works perfectly in this mode. My problem is that I need to use Half-Duplex mode because on hardware I have output data from AD7686 connected to the MOSI pin which I need to read using DMA which is triggered by a timer. Here is the configuration which works for me but only in Fuul-Duplex mode.

Timer 2 is used to trigger DMA and the CH1 output generates the CNV signal for the AD7686

SET_BIT(SPI2->CR2,SPI_CR2_RXDMAEN);
HAL_DMA_Start_IT(&hdma_spi2_rx,(uint32_t)&(SPI2->DR),(uint32_t)U_RX_buf,U_RX_BUF_SIZE);
__HAL_SPI_ENABLE(&hspi2);
HAL_DMA_Start(&hdma_tim2_ch1,(uint32_t)&tx_buffer,(uint32_t)&(SPI2->DR),1);
HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_1);
__HAL_TIM_ENABLE_DMA(&htim2,TIM_DMA_CC1);

    This topic has been closed for replies.

    1 reply

    ST Employee
    May 22, 2025

    Hello @Folny,

    You can explore the example available with STM32CubeL4: SPI_HalfDuplex_ComPolling

    Additionally, I recommend checking out this article: Getting started with SPI (STMicroelectronics)

    I hope my answer has helped you. When your question is answered, please select this topic as the solution that answered you, as it will help others find that answer faster.

    Thanks for your contribution.

    Dor_RH