当前位置:网站首页>Stm32f4-tft-spi timing logic analyzer commissioning record

Stm32f4-tft-spi timing logic analyzer commissioning record

2022-07-01 15:24:00 Please call me Chang Sicong

debugging TFT I don't know whether the data is written TFT
Connect the logic analyzer to see ,

Because I'm not sure about software SPI Whether it can be used , So first use hardware SPI test
Then switch to Software SPI
 Insert picture description here
It is right to test the timing , Normal display
 Insert picture description here
The code is as follows
 Insert picture description here
Then turn on the logic analyzer I use it logic2, Set as follows , Pay attention to the settings in the red box ,( Change it to CPHA=1 The displayed data is not right )
 Insert picture description here
You can see that all the data written is 0xF800, Macro definition RGB565 Red is 0xF800
 Insert picture description here
 Insert picture description here

 Insert picture description here
Look at what else is written in this write fill function ,

void LCD_direction(u8 direction)
{
     
			lcddev.setxcmd=0x2A;
			lcddev.setycmd=0x2B;
			lcddev.wramcmd=0x2C;
	switch(direction){
    		  
		case 0:						 	 		
			lcddev.width=LCD_W;
			lcddev.height=LCD_H;	
			lcddev.xoffset=52;
			lcddev.yoffset=40;
			LCD_WriteReg(0x36,0);//BGR==1,MY==0,MX==0,MV==0
		break;
		case 1:		//select direction=1
			lcddev.width=LCD_H;
			lcddev.height=LCD_W;
			lcddev.xoffset=40;
			lcddev.yoffset=53;
			LCD_WriteReg(0x36,(1<<6)|(1<<5));//BGR==1,MY==1,MX==0,MV==1
		break;
		case 2:						 	 		
			lcddev.width=LCD_W;
			lcddev.height=LCD_H;
			lcddev.xoffset=53;
			lcddev.yoffset=40;			
			LCD_WriteReg(0x36,(1<<6)|(1<<7));//BGR==1,MY==0,MX==0,MV==0
		break;
		case 3:
			lcddev.width=LCD_H;
			lcddev.height=LCD_W;
			lcddev.xoffset=40;
			lcddev.yoffset=52;
			LCD_WriteReg(0x36,(1<<7)|(1<<5));//BGR==1,MY==1,MX==0,MV==1
		break;	
		default:break;
	}				
}	 
void LCD_WriteRAM_Prepare(void)
{
    
	LCD_WR_REG(lcddev.wramcmd); //lcddev.wramcmd=0x2C
}	

lcddev.setxcmd Parameter in void LCD_direction(u8 direction) There are updates inside ,lcddev.setxcmd=0x2A

#define LCD_W 135 //TFT 1.14
#define LCD_H 240

void LCD_Fill(u16 sx,u16 sy,u16 ex,u16 ey,u16 color)
{
      	
	u16 i,j;			
	u16 width=ex-sx+1; 		// Get the width of the fill 
	u16 height=ey-sy+1;		// Height 
	LCD_SetWindows(sx,sy,ex,ey);// Set the display window 
	for(i=0;i<height;i++)
	{
    
		for(j=0;j<width;j++)
		Lcd_WriteData_16Bit(color);	// Write data  
	}
	LCD_SetWindows(0,0,lcddev.width-1,lcddev.height-1);// The recovery window is set to full screen 
}
void LCD_SetWindows(u16 xStar, u16 yStar,u16 xEnd,u16 yEnd)
{
    	
	LCD_WR_REG(lcddev.setxcmd);				//0x2A
	LCD_WR_DATA((xStar+lcddev.xoffset)>>8); //(0+40)>>8=0x00
	LCD_WR_DATA(xStar+lcddev.xoffset);		//0x28
	LCD_WR_DATA((xEnd+lcddev.xoffset)>>8);	//(240+40)>>8=0x01
	LCD_WR_DATA(xEnd+lcddev.xoffset);		//0x18

	LCD_WR_REG(lcddev.setycmd);				//0x2B
	LCD_WR_DATA((yStar+lcddev.yoffset)>>8);	//0+53 >>8=0x00
	LCD_WR_DATA(yStar+lcddev.yoffset);		//0x35
	LCD_WR_DATA((yEnd+lcddev.yoffset)>>8);	//135+53 >>8=0x00
	LCD_WR_DATA(yEnd+lcddev.yoffset);		//0xBC

	LCD_WriteRAM_Prepare();	// Start writing GRAM //lcddev.wramcmd=0x2C 
}   

Therefore, the beginning of the data should be :
0x2A–0x00–0x28–0x01–0x18------0x2B–0x00–0x35–0x00–0x35–0x00–0xBC-----0x2C-----0xF8-0x00–0xF8-0x00…
Data captured by logic analyzer :
 Insert picture description here
The captured data is consistent with the calculation .

原网站

版权声明
本文为[Please call me Chang Sicong]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/182/202207011515546950.html