cancel
Showing results for 
Search instead for 
Did you mean: 

DMA2S issues configurations

Luca G.
Associate III

I am using the DMA2D in STM32F750Z8T's perform operations on buffers that are in external RAM.

I am using it for drawing on the display, so I have the LTDC device active and the synchronization interrupt active.

The first thing I do is fill a buffer with a unique value and the code is as follows:

bool FillBuffer(uint32_t Xpos, uint32_t Ypos, uint32_t xSize, uint32_t ySize, uint32_t color)
{
    uint32_t DstAddress;
	
    hdma2d->Init.Mode = DMA2D_R2M;
    hdma2d->Init.ColorMode = DMA2D_OUTPUT_ARGB8888;
    hdma2d->Init.OutputOffset = (GetXSize() - xSize); //GetXSize() return the maximum X size in pixel.
 
    //Do not set the level settings because it is not necessary in this mode
 
    DstAddress = ((uint32_t)temporary_buffer) + (GetXSize() * Ypos + Xpos) * 4; //GetXSize() return the maximum X size in pixel.
 
    /* DMA2D Initialization */
    if(HAL_DMA2D_Init(hdma2d) == HAL_OK)
    {
        if(HAL_DMA2D_Start(hdma2d, color, DstAddress, xSize, ySize) == HAL_OK)
        {
            /* Polling For DMA transfer */
            if(HAL_DMA2D_PollForTransfer(hdma2d, 1000) == HAL_OK)
            {
                return true;
            }
        }
    }
 
    return false;
}

The problem that occurs is that when I run "HAL_DMA2D_PollingForTransfer" it gives me an error. Entering the function, the TCIF and CEIF flags are both set. Shouldn't CEIF just be set?

It seems that the problem is solved by using a HAL_Delay(1) before calling "HAL_DMA2D_PollingForTransfer". Where could be the probleme?

The second thing I do is copy between buffers and the code is as follows:

bool CopyBuffers(uint32_t *pSrc, uint32_t *pDst, uint32_t xSize, uint32_t ySize)
{
    uint32_t DstAddress;
 
    hdma2d->Init.Mode = DMA2D_M2M;
    hdma2d->Init.ColorMode = DMA2D_OUTPUT_ARGB8888;
    hdma2d->Init.OutputOffset = 0;
 
    hdma2d->LayerCfg[DMA2D_BACKGROUND_LAYER].AlphaMode = DMA2D_NO_MODIF_ALPHA;
    hdma2d->LayerCfg[DMA2D_BACKGROUND_LAYER].InputAlpha = 0xFF;
    hdma2d->LayerCfg[DMA2D_BACKGROUND_LAYER].InputColorMode = DMA2D_INPUT_ARGB8888;
    hdma2d->LayerCfg[DMA2D_BACKGROUND_LAYER].InputOffset = 0;
 
    hdma2d->LayerCfg[DMA2D_FOREGROUND_LAYER].AlphaMode = DMA2D_NO_MODIF_ALPHA;
    hdma2d->LayerCfg[DMA2D_FOREGROUND_LAYER].InputAlpha = 0xFF;
    hdma2d->LayerCfg[DMA2D_FOREGROUND_LAYER].InputColorMode = DMA2D_INPUT_ARGB8888;
    hdma2d->LayerCfg[DMA2D_FOREGROUND_LAYER].InputOffset = 0;
 
    DstAddress = ((uint32_t)temporary_buffer) + (GetXSize() * Ypos + Xpos) * 4; //GetXSize() return the maximum X size in pixel.
 
    /* DMA2D Initialization */
    if(HAL_DMA2D_Init(hdma2d) == HAL_OK)
    {
        if(HAL_DMA2D_ConfigLayer(hdma2d, DMA2D_BACKGROUND_LAYER) == HAL_OK)
        {
            if(HAL_DMA2D_ConfigLayer(hdma2d, DMA2D_FOREGROUND_LAYER) == HAL_OK)
            {
                if(HAL_DMA2D_Start(hdma2d, color, DstAddress, xSize, ySize) == HAL_OK)
                {
                     /* Polling For DMA transfer */
                    if(HAL_DMA2D_PollForTransfer(hdma2d, 1000) == HAL_OK)
                    {
                        return true;
                    }
                }
            }
        }
    }
 
    return false;
}

The problem that occurs also here is the same as in the previous case but cannot be solved by putting the delay. Also in this case the TCIF and CEIF flags are both set.

Also for this one, where could be the problem?

Is there some configuration set wrong?

The display uses an 8888 color coding and RAM is also used with this color coding.

Having a 32bit (8888) color coding, the addresses passed to the DMA2D should always be aligned.

Thanks in advance.

Luca G.

1 ACCEPTED SOLUTION

Accepted Solutions
Luca G.
Associate III

Maybe I found the problem: if xSize or ySize are equal to 0, DMA2D generates the configuration error and in any case sets the transmission flag.

I have not found this indication in the manual and it also seems strange to me that both flags are set (CEIF and TCIF).

Luca G.

View solution in original post

1 REPLY 1
Luca G.
Associate III

Maybe I found the problem: if xSize or ySize are equal to 0, DMA2D generates the configuration error and in any case sets the transmission flag.

I have not found this indication in the manual and it also seems strange to me that both flags are set (CEIF and TCIF).

Luca G.