cancel
Showing results for 
Search instead for 
Did you mean: 

ISSUE about DMA2D transfer in a RGB LCD project

KaoChin
Associate

I use CubeMX to construct a project for RGB LCD in a STM32F767 custom board.

MPU is enable, and is set as follow

0693W000008xjrPQAQ.pngSDRAM is used and FMC is set as :

0693W000008xjroQAA.png0693W000008xjrpQAA.pngDMA2D is actived and set as :

0693W000008xjsIQAQ.png

the LTDC is set as :

0693W000008xjswQAA.png0693W000008xjt1QAA.png​The following code is used to fill the LCD with color :

void LTDC_Fill(u16 sx,u16 sy,u16 ex,u16 ey,u32 color)
{ 
	printf("Enter LTDC_Fill color=%d \r\n",color);
	u32 psx,psy,pex,pey;	//¥HLCD­±ªO¬°°ò·Çªº§¤¼�?¨t,¤£ÀH¾î½�?«ÌÅܤƦÓÅܤÆ
	u32 timeout=0; 
	u16 offline;
	u32 addr; 
	//§¤¼�?¨tÂà´«
	if(lcdltdc.dir)	//¾î«Ì
	{
		psx=sx;psy=sy;
		pex=ex;pey=ey;
	}else			//½�?«Ì
	{
		psx=sy;psy=lcdltdc.pheight-ex-1;
		pex=ey;pey=lcdltdc.pheight-sx-1;
	} 
	
	offline=lcdltdc.pwidth-(pex-psx+1);
	printf("pex=%d pey=%d  offline=%d  ",pex,pey,offline);
	addr=LCD_FRAME_BUF_ADDR+2*(LCD_W*psy+psx);//((u32)ltdc_framebuf[lcdltdc.activelayer]+lcdltdc.pixsize*(lcdltdc.pwidth*psy+psx));
	printf("addr = 0x%x \r\n",addr);
	printf("enable RCC->AHB1EN ");	
	RCC->AHB1ENR|=1<<23;			//enable DMA2D clock
	printf("RCC->AHB1EN =0x%x \r\n",RCC->AHB1ENR);
	printf("write DMA2D : \r\n");	
	printf("stop DAM2D: CR = 0x%x --> ", DMA2D->CR);
	DMA2D->CR&=~(DMA2D_CR_START);	//stop MAM2D
	printf("0x%x \r\n", DMA2D->CR);
	DMA2D->CR=3<<16;				//set mode as register to mem 
	printf("DMA2D->CR = 0x%x \r\n",DMA2D->CR);
	DMA2D->OPFCCR=LCD_PIXFORMAT;	//LCD_PIXFORMAT = LCD_PIXEL_FORMAT_RGB565	
	printf("DMA2D->OPFCCR = 0x%x \r\n",DMA2D->OPFCCR);
	DMA2D->OOR=offline;				 
	printf("DMA2D->OOR = 0x%x \r\n",DMA2D->OOR);
	DMA2D->CR&=~(1<<0);				//stop DMA2D
	printf("DMA2D->CR = 0x%x \r\n",DMA2D->CR);
	DMA2D->OMAR=addr;				//addr = 0xc000000
	printf("DMA2D->OMAR = 0x%x \r\n",DMA2D->OMAR);
	DMA2D->NLR=(pey-psy+1)|((pex-psx+1)<<16);	//set line reg  
	printf("DMA2D->NLR = 0x%x \r\n",DMA2D->NLR);
	DMA2D->OCOLR=color;				//set color reg 
	printf("DMA2D->OCOLR = 0x%x \r\n",DMA2D->OCOLR);
	DMA2D->CR|=1<<0;				//start DMA2D
	printf("DMA2D->CR = 0x%x \r\n",DMA2D->CR);
	printf("write DAM2D finish and transfer data \r\n");
	//while((DMA2D->ISR&(1<<1))==0)	
	while((DMA2D->ISR&(DMA2D_FLAG_TC))==0) //waiting for	
	{
		timeout++;
		if(timeout>0X1FFFFF)
    {
			printf("DMA2D data transfer timeout !!  DMA2D->ISR=0x%x  DMA2D_FLAG_TC=0x%x \r\n",DMA2D->ISR, DMA2D_FLAG_TC);
			break;	//time out break 
		}
	}  
	DMA2D->IFCR|=1<<1;				//clear trans complete flag	
	printf("DMA2D->IFCR = 0x%x \r\n",DMA2D->IFCR);
	printf("--------LTDC_Fill Finish-------\r\n");
}

The fill LCD code is called twice. The information printed via usart is shown as follow :

---------- enter MX_LTDC --------------------

FBStartAdress= 0xc0000000 lendingFactor1=0x600 BlendingFactor2==0x7

ImageWidth=1024 ImageHeight=600

Backcolor.Red=0x0 Backcolor.Green=0x0 Backcolor.Blue=0x0

Layer 0 Window Config: x0=0  y0=0  w=1024  h=600

LCD_dir=1 lcdltdc.width=1024 lcdltdc.height=600

lcd_actived_layer =0

enter LTDC_Clear, lcdltdc.width=1024 lcdltdc.height=600 color=65535

Enter LTDC_Fill color=65535

pex=1023 pey=599 offline=0 addr = 0xc0000000

enable RCC->AHB1EN RCC->AHB1EN =0x9001ff

write DMA2D :

stop DAM2D: CR = 0x0 --> 0x0

DMA2D->CR = 0x30000

DMA2D->OPFCCR = 0x2

DMA2D->OOR = 0x0

DMA2D->CR = 0x30000

DMA2D->OMAR = 0xc0000000

DMA2D->NLR = 0x4000258

DMA2D->OCOLR = 0xffff

DMA2D->CR = 0x30001

write DAM2D finish and transfer data

DMA2D data transfer timeout !! DMA2D->ISR=0x0 DMA2D_FLAG_TC=0x2

DMA2D->IFCR = 0x0

--------LTDC_Fill Finish-------

enter LTDC_Clear, lcdltdc.width=1024 lcdltdc.height=600 color=65535

Enter LTDC_Fill color=65535

pex=1023 pey=599 offline=0 addr = 0xc0000000

enable RCC->AHB1EN RCC->AHB1EN =0x9001ff

write DMA2D :

stop DAM2D: CR = 0x30001 --> 0x30001

DMA2D->CR = 0x30001

DMA2D->OPFCCR = 0x2

DMA2D->OOR = 0x0

DMA2D->CR = 0x30001

DMA2D->OMAR = 0xc0000000

DMA2D->NLR = 0x4000258

DMA2D->OCOLR = 0xffff

DMA2D->CR = 0x30001

write DAM2D finish and transfer data

DMA2D data transfer timeout !! DMA2D->ISR=0x0 DMA2D_FLAG_TC=0x2

DMA2D->IFCR = 0x0

--------LTDC_Fill Finish-------

At the first call, the DMA2D is stop via set DMA2D->CR as 0x30000 and then set the DAM2D parameter, start the DMA2D via set DMA2D->CR as 0x30001, but timeout in data transfer finally.

At the second call, the DMA2D can not be stop via as DMA2D->CR as 0x30000, is always in start siutation, and can not be set as 0x30000 to stop the DMA2D. I suspect that the data can not be transfered and causes the DAM2D to be died, but I can not find the reason.

I have checked the other setting such as GPIO and clock with the driver provided via custom board vendor that can run correctly.

Could anyone give me suggestion? Thank for your help! best wishes.

0 REPLIES 0