2025-04-23 3:51 PM - last edited on 2025-05-20 2:12 AM by Amel NASRI
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);
2025-05-22 4:06 AM
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