cancel
Showing results for 
Search instead for 
Did you mean: 

DMA is freezing

Despair1337
Associate III

Hello, I have my project based on STM32H753I-EVAL with RGB LCD display and SDRAM.

I'm using DMA2D to render lines with CLUT L8 (Pulling mode). Basically, I process data for one line (one line have 320 pixels), and then execute it 108 times (for height). I'm rendering this 30 times per second. But for some reason, it sometimes render black (so it's blinking) (where data are correct), or it just freeze (since it's polling mode, it's frozen in checking if transfer was finished). After it timeout, it tries once again, until after few seconds it starts work again and then again freeze. I would expect that somewhere in code I have issue, but the exactly same code, used on STM32F429-DISC1, it works absolutely fine.

So it looks like it's not my code problem, but my several concerns are:

1) SDRAM - I tried to verify if SDRAM have correct clock and configuration according to EVAL example, everything looks good

2) Broken DMA IP Core inside H7?

3) Other clock problem

I'm totally out of ideas, since it works correctly on F4. Here is my code, configuration and clock tree.

DMA2D_HandleTypeDef Dma2dHandle;
  DMA2D_CLUTCfgTypeDef CLUTCfg;
 
  /* Configure the DMA2D Mode, Color Mode and output offset */
  Dma2dHandle.Init.Mode         = DMA2D_M2M_PFC;         /* DMA2D mode Memory to Memory with Pixel Format Conversion */
  Dma2dHandle.Init.ColorMode    = DMA2D_OUTPUT_ARGB8888; /* output format of DMA2D */
  Dma2dHandle.Init.OutputOffset = 0x0;                   /* No offset in output */
#ifdef STM32F7
  Dma2dHandle.Init.AlphaInverted = DMA2D_REGULAR_ALPHA;  /* No Output Alpha Inversion*/
  Dma2dHandle.Init.RedBlueSwap   = DMA2D_RB_REGULAR;     /* No Output Red & Blue swap */
#endif
 
 
  /* Foreground layer Configuration */
  Dma2dHandle.LayerCfg[1].AlphaMode = DMA2D_REPLACE_ALPHA;
  Dma2dHandle.LayerCfg[1].InputAlpha = 0xFF;                   /* Fully opaque */
  Dma2dHandle.LayerCfg[1].InputColorMode = DMA2D_INPUT_L8;     /* Input Color mode is L8 : indexed 256 color image */
  Dma2dHandle.LayerCfg[1].InputOffset = 0x0;                   /* No offset in input */
#ifdef STM32F7
  Dma2dHandle.LayerCfg[1].AlphaInverted = DMA2D_REGULAR_ALPHA; /* No ForeGround Alpha inversion*/
  Dma2dHandle.LayerCfg[1].RedBlueSwap   = DMA2D_RB_REGULAR;    /* No ForeGround Red/Blue swap*/
#endif
 
  Dma2dHandle.Instance = DMA2D;
 
  /* DMA2D Initialization */
  HAL_DMA2D_DeInit(&Dma2dHandle);
  HAL_DMA2D_Init(&Dma2dHandle);
  /* Apply DMA2D Foreground configuration */
  HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1);
 
  /* Load DMA2D Foreground CLUT */
  CLUTCfg.CLUTColorMode = DMA2D_CCM_ARGB8888;
  CLUTCfg.pCLUT = (uint32_t *)clut;
  CLUTCfg.Size = 255;
 
  HAL_DMA2D_CLUTLoad(&Dma2dHandle, CLUTCfg, 1);
  HAL_DMA2D_PollForTransfer(&Dma2dHandle, 1000);
 
  for (int y = 0; y < 108; y++) {
     for (int x = 0; x < 320; x++) {
         // addr is targeting to SDRAM memory address
         HAL_DMA2D_Start(&Dma2dHandle, (uint32_t)&buff, (uint32_t)addr, 320, 1);
         HAL_DMA2D_PollForTransfer(&Dma2dHandle, 10);
     }
  }

ClockTree 1: 0693W000006GkNqQAK.png 

0693W000006GkOjQAK.png0693W000006GkP3QAK.png

1 ACCEPTED SOLUTION

Accepted Solutions
Despair1337
Associate III

Fixed here: Feed Detail (st.com)

In nutshell, check your DMA2D errors everywhere.

View solution in original post

3 REPLIES 3
Despair1337
Associate III

Bump. Nobody? :\

Okay, I probably got reason why this happens. It's because STM32F7/H7 have caching and all those related things.

Although, I still didn't found the issue.

Despair1337
Associate III

Fixed here: Feed Detail (st.com)

In nutshell, check your DMA2D errors everywhere.