Skip to main content
Visitor II
July 21, 2025
Question

Trigger SPI6 DMA transfer using external pin via DMAMUX

  • July 21, 2025
  • 4 replies
  • 338 views

 

Hello,

I'm working with the STM32H723 and need to interface with an external ADC that provides a DRDY (PG2 pin) signal. I'd like to initiate an SPI transfer via DMA whenever the DRDY pin goes low. The ADC is connected to SPI6, and I understand that only BDMA can be used with this peripheral.

My main question is:
How can I configure DMAMUX to trigger a BDMA transfer for SPI6 when the DRDY pin goes low?

I'm using STM32CubeMX for configuration. I’ve looked through existing forum posts and the STM documentation, but haven’t found a clear example or explanation for this setup. Any guidance, examples, or tips to get started would be greatly appreciated.

Thanks in advance!

    This topic has been closed for replies.

    4 replies

    Super User
    July 21, 2025

    According to DMAMUX2 and BDMA connections table in RM0468, exti_syscfg_exti2 is an input to the DMAMUX generator, as dmamux2_gen21, so this should be doable by selecting PG2 in the EXTI2 selector in SYSCFG and setting up DMA generation in DMAMUX2. I don't use Cube, so can't help with that; but I'd assume there's some clicking related to these facts in CubeMX. Maybe somebody versed in CubeMX will chime in with the details.

    I presume you already know how to set up SPI with DMA - I do not know that, SPI in 'H7 is an overcomplicated beast and I don't use the 'H7.

    JW

     

    gotthardAuthor
    Visitor II
    July 22, 2025
    My configuration is as follows:
     
    /* Local variables */
    HAL_DMA_MuxRequestGeneratorConfigTypeDef pRequestGeneratorConfig = { 0 };
    
    /* DMA controller clock enable */
    __HAL_RCC_BDMA_CLK_ENABLE();
    
    /* Configure DMA request hdma_bdma_generator0 on BDMA_Channel1 */
    hdma_bdma_generator0.Instance = BDMA_Channel1;
    hdma_bdma_generator0.Init.Request = BDMA_REQUEST_GENERATOR0;
    hdma_bdma_generator0.Init.Direction = DMA_MEMORY_TO_PERIPH;
    hdma_bdma_generator0.Init.PeriphInc = DMA_PINC_DISABLE;
    hdma_bdma_generator0.Init.MemInc = DMA_MINC_ENABLE;
    hdma_bdma_generator0.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
    hdma_bdma_generator0.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
    hdma_bdma_generator0.Init.Mode = DMA_NORMAL;
    hdma_bdma_generator0.Init.Priority = DMA_PRIORITY_LOW;
    if (HAL_DMA_Init(&hdma_bdma_generator0) != HAL_OK) {
    Error_Handler();
    }
    
    /* Configure the DMAMUX request generator for the selected BDMA channel */
    pRequestGeneratorConfig.SignalID = HAL_DMAMUX2_REQ_GEN_EXTI2;
    pRequestGeneratorConfig.Polarity = HAL_DMAMUX_REQ_GEN_FALLING;
    pRequestGeneratorConfig.RequestNumber = 1;
    if (HAL_DMAEx_ConfigMuxRequestGenerator(&hdma_bdma_generator0,
    &pRequestGeneratorConfig) != HAL_OK) {
    Error_Handler();
    }
    
    hdma_spi6_tx.Instance = BDMA_Channel0;
    hdma_spi6_tx.Init.Request = BDMA_REQUEST_SPI6_TX;
    hdma_spi6_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
    hdma_spi6_tx.Init.PeriphInc = DMA_PINC_DISABLE;
    hdma_spi6_tx.Init.MemInc = DMA_MINC_ENABLE;
    hdma_spi6_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
    hdma_spi6_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
    hdma_spi6_tx.Init.Mode = DMA_NORMAL;
    hdma_spi6_tx.Init.Priority = DMA_PRIORITY_HIGH;
    
    HAL_DMA_Init(&hdma_spi6_tx);
    __HAL_LINKDMA(&hspi6, hdmatx, hdma_spi6_tx);
    
    MX_SPI6_Init();
    
    HAL_DMAEx_EnableMuxRequestGenerator(&hdma_bdma_generator0);
    HAL_SPI_Transmit_DMA(&hspi6, dmaBuffer, 10);
     
    My SPI width is configured to 8 bits and I would like to transmit 10x8 bits. When request generator is enabled I see that only 8 bits are transferred when EXTI2 pin goes low and this happens 10 times and then it stops. 
    How to achieve 10x8 bits in a single transfer when EXTI2 is low? Also, I would like to point out that my chip select is constantly tied low. 
     
    Super User
    July 22, 2025

    I don't use Cube/HAL, but I'd guess here

    pRequestGeneratorConfig.RequestNumber = 1;

    you have to set 10.

    JW

    gotthardAuthor
    Visitor II
    July 22, 2025

    Unfortunately, it did not work. Only 8 bits were transferred. 

    Super User
    July 22, 2025

    Read out and check/post content of relevant DMA and DMAMUX registers.

    > hdma_bdma_generator0.Instance = BDMA_Channel1;

    > hdma_spi6_tx.Instance = BDMA_Channel0;

    As I've said, I don't use Cube, but how do these things add up?

    JW