cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5 - application with both normal and LPBAM I2C routine with LPDMA and GPDMA

andrenada
Associate

Hy,

I am trying to implement a code where i am using the I2C3 both in normal mode through the GPDMA and in LPDMA through the linked list.

Switching from the normal mode through the LPBAM linkest list works correctly but then moving back always makes the I2C unusable. 

 

The main procedure to go back is the following:

    SystemClock_Config();
    HAL_ResumeTick();
 
    __HAL_RCC_I2C3_CLK_ENABLE();
    __HAL_RCC_GPDMA1_CLK_ENABLE();
    __HAL_RCC_GPIOC_CLK_ENABLE();
 
    hi2c3.Instance->CR1 &= ~I2C_CR1_PE;
    hi2c3.Instance->AUTOCR = 0;
 
    HAL_DMA_Abort(&handle_LPDMA1_Channel0);
    HAL_DMAEx_List_UnLinkQ(&handle_LPDMA1_Channel0);
    HAL_DMA_DeInit(&handle_LPDMA1_Channel0);
 
    hi2c3.State = HAL_I2C_STATE_RESET;
    handle_GPDMA1_Channel0.State = HAL_DMA_STATE_RESET;
 
    MX_GPDMA1_Init();
    MX_I2C3_Init();
 
    __HAL_LINKDMA(&hi2c3, hdmarx, handle_GPDMA1_Channel0);
 
As for the LPBAM i don't have too much experience and I don't understand where the problem could be.
 
Hope someone has some suggestion on how to fix.
Thanks
1 REPLY 1
Saket_Om
ST Employee

Hello @andrenada 

When you say “I2C becomes unusable”, that can mean several different things.

Check which one happens:

  • HAL_I2C_Master_Transmit_DMA() returns error immediately
  • transfer starts but callback never arrives
  • peripheral remains busy
  • DMA interrupt never fires
  • bus lines are stuck
  • NACK/STOP/BERR appears immediately
To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om