Skip to main content
Visitor II
May 6, 2022
Question

STM32H7 DMA stops after first transfer

  • May 6, 2022
  • 6 replies
  • 2061 views

I tested this example from the STM32CubeH7 repository and it works fine.

When I try the DMA1 instead of the BDMA, the DMA stops after the first transfer.

I made only the following changes to use the DMA1

__HAL_RCC_DMA1_CLK_ENABLE();		// Enable the clock for DMA1
DMA_Handle.Instance = DMA1_Stream0	// Instance = DMA1_Stream0 instead of BDMA_Channel0
DMA_Handle.Init.Request = DMA_REQUEST_GENERATOR0;	// DMA request instead of BDMA request
dmamux_ReqGenParams.SignalID = HAL_DMAMUX1_REQ_GEN_LPTIM2_OUT	// DMAMUX1 instead of DMAMUX2

    This topic has been closed for replies.

    6 replies

    Super User
    May 7, 2022

    > the DMA stops after the first transfer

    How do you know there was the first transfer, and then how do you know it stopped?

    Read out and checkpost DMA, DMAMUX and LPTIM2 registers content.

    JW

    Graduate II
    May 7, 2022

    Check for errors and status flags.

    Check memory addresses are accessible, and suitably aligned.

    Dump registers for all associated peripherals.

    Check cache coherency.​

    JKuen.2Author
    Visitor II
    May 7, 2022

    Sorry I did not explain that more detailed.. Yes I check the register content..

    The DMA.NDTR. register decrements by one and then stand still.

    But what I also forgot to mention is the fact, that I tested the EXTI0 using (HAL_DMAMUX1_REQ_GEN_EXTI0 instead of the LPTIM2-timer. Indeed together with the timer it works with both DMAs (BDMA and DMA1) but with the EXTI0 input it works only with BDMA but not with DMA1.

    Testing the EXTI0 input, I connected the related input (PE0) with an GPIO-output and toggle this output by software,

    while (1) {
     HAL_GPIO_WritePin(DMA_TRG_GPIO_Port, DMA_TRG_Pin, GPIO_PIN_SET);
    	HAL_GPIO_WritePin(DMA_TRG_GPIO_Port, DMA_TRG_Pin, GPIO_PIN_RESET);
     HAL_Delay (200);
    }

    When using the DMA1 I can see the first transfer, NDTR decrements by one and LED switches on due to the DMA transfer) but on the next trigger toggle nothing happens.

    I’m wondering that EXTI0 works withd BDMA but not with DMA1

    Super User
    May 7, 2022

    Try to put delay also between the two HAL_GPIO_WritePin().

    JW

    JKuen.2Author
    Visitor II
    May 7, 2022

    I tried that already, also tested with the debugger step by step.

    Graduate II
    May 7, 2022

    Dump and post DMA registers

    Super User
    May 8, 2022

    Which STM32 exactly?

    And read/post also the DMAMUX registers content.

    Looking into RM0433, I see no EXTI0 request input to either DMAMUX. I see some extit0 (and I don't know what does that mean) trigger and synchronization input to DMAMUX1 but not to DMAMUX2. So I'm confused how did you get that working with BDMA.

    JW

    Explorer II
    March 19, 2025

    Hi,

     

    I use HAL_I2C_Mem_Read_DMA to read IMU and magnetometer data from LSM9ds1

     

    in loop():

    //read acceleometer

    if (accReady) {

    // Reset flags for continuous operation

    accReady = 0;

    while (HAL_I2C_GetState(&hi2c1) != HAL_I2C_STATE_READY)

    {

    }

    // Restart readings

    HAL_I2C_Mem_Read_DMA(&hi2c1, LSM9DS1_IMU_I2C_ADD_H , LSM9DS1_OUT_X_L_XL, I2C_MEMADD_SIZE_8BIT, rxDataACC, RX_BUFF_LEN);

    }

     

    the callback:

     

    void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c) {

    if (hi2c->Instance == I2C1) {

    if (!accReady) {

    // acc read complete, start accelerometer read

    accReady = 1;

    }

    HAL_DMA_Abort_IT(hi2c->hdmarx);

    }

    }