这个屏幕是给VerilogBoy实体机使用的屏幕,MIPI DSI接口,因为以前从来没有点过MIPI的屏幕,这里记录下过程方便以后参考。

1543943583616-photo_2018-12-04_12-13-56.jpg

基本信息

  • 型号:AML-B16C15012Q
  • 类型:RGB IPS TFT-LCD
  • 模式:Normal Black
  • 分辨率:320x320
  • 灰度:接口支持8bpc,内部显存为6bpc,实际输出可能为6bpc
  • 控制器:ST7796S
  • 尺寸:1.54"
  • 接口:MIPI 1-lane
  • 背光:3并,VF=3.2V

接口定义

  1. LEDA
  2. LEDK
  3. VCC 2.8
  4. RESET
  5. NC
  6. NC
  7. NC
  8. VCCIO 1.8
  9. GND
  10. DATA0_P
  11. TE
  12. DATA0_N
  13. NC
  14. GND
  15. GND
  16. CLK_P
  17. NC
  18. CLK_N
  19. NC
  20. GND

笔记

  • 时钟线最大频率500MHz,最低频率80MHz
  • LP模式下DS要求每个状态保持时间为35-75ns,实测100ns也可行
  • 0x2C通过LPDT无法正确写入数据(短包长包都不行),0x3C可行(仅限长包)

初始化

	Delay_ms(120); 
	 
	GP_COMMAD_PA(2);
	SPI_WriteData(0x36); // Memory data access control  
	SPI_WriteData(0x48); // Reverse X, BGR
	 
	GP_COMMAD_PA(2);
	SPI_WriteData(0x3A); // Interface pixel format
	SPI_WriteData(0x77); // 16.7M Color (not defined in DS???)
	 
	GP_COMMAD_PA(2);
	SPI_WriteData(0xF0); // Command Set Control
	SPI_WriteData(0xC3); // Enable Command 2 Part I
	 
	GP_COMMAD_PA(2);
	SPI_WriteData(0xF0); // Command Set Control
	SPI_WriteData(0x96); // Enable Command 2 Part II
	 
	GP_COMMAD_PA(3);
	SPI_WriteData(0xB1); // Frame Rate Control
	SPI_WriteData(0xA0); // FRS = 10 DIVA = 0 RTNA = 32
	SPI_WriteData(0x10); // FR = 10^7 / ((168+RTNA+32x(15-FRS))(320+VFP+VBP))
	 
	GP_COMMAD_PA(2);
	SPI_WriteData(0xB4); // Display Inversion Control
	SPI_WriteData(0x00); // 00: Column INV, 01: 1-Dot INV, 10: 2-Dot INV   
	 
	GP_COMMAD_PA(5);
	SPI_WriteData(0xB5); // Blacking Porch Control
	SPI_WriteData(0x40); // VFP = 64
	SPI_WriteData(0x40); // VBP = 64
	SPI_WriteData(0x00); // Reserved
	SPI_WriteData(0x04); // HBP = 4

	GP_COMMAD_PA(4);
	SPI_WriteData(0xB6); // Display Function Control
	SPI_WriteData(0x8A); // Bypass RAM, DE mode
	SPI_WriteData(0x07); // Non inverting
	SPI_WriteData(0x27); // 8*(0x27+1) = 320 lines
	 
	GP_COMMAD_PA(2);
	SPI_WriteData(0xB9); // There is no B9 in datasheet
	SPI_WriteData(0x02); 
	 
	GP_COMMAD_PA(2);
	SPI_WriteData(0xC5); // VCOM Control
	SPI_WriteData(0x2E); // 1.450V
	 
	GP_COMMAD_PA(9);
	SPI_WriteData(0xE8); // Display Output
	SPI_WriteData(0x40); 
	SPI_WriteData(0x8A); 
	SPI_WriteData(0x00); 
	SPI_WriteData(0x00); 
	SPI_WriteData(0x29); 
	SPI_WriteData(0x19); 
	SPI_WriteData(0xA5); 
	SPI_WriteData(0x93); 
	 
	GP_COMMAD_PA(15);
	SPI_WriteData(0xe0); // Positive Gamma Control
	SPI_WriteData(0xf0); 
	SPI_WriteData(0x07); 
	SPI_WriteData(0x0e); 
	SPI_WriteData(0x0a); 
	SPI_WriteData(0x08); 
	SPI_WriteData(0x25); 
	SPI_WriteData(0x38); 
	SPI_WriteData(0x43); 
	SPI_WriteData(0x51); 
	SPI_WriteData(0x38); 
	SPI_WriteData(0x14); 
	SPI_WriteData(0x12); 
	SPI_WriteData(0x32); 
	SPI_WriteData(0x3f); 

	GP_COMMAD_PA(15);
	SPI_WriteData(0xe1); // Negative Gamma Control
	SPI_WriteData(0xf0); 
	SPI_WriteData(0x08); 
	SPI_WriteData(0x0d); 
	SPI_WriteData(0x09); 
	SPI_WriteData(0x09); 
	SPI_WriteData(0x26); 
	SPI_WriteData(0x39); 
	SPI_WriteData(0x45); 
	SPI_WriteData(0x52); 
	SPI_WriteData(0x07); 
	SPI_WriteData(0x13); 
	SPI_WriteData(0x16); 
	SPI_WriteData(0x32); 
	SPI_WriteData(0x3f); 
	 
	GP_COMMAD_PA(2);
	SPI_WriteData(0xF0); // Command Set Control
	SPI_WriteData(0x3C); // Disable Command 2 Part I
	 
	GP_COMMAD_PA(2);
	SPI_WriteData(0xF0); // Command Set Control
	SPI_WriteData(0x69); // Disable Command 2 Part II
	 
	GP_COMMAD_PA(1),   
	SPI_WriteData(0x11); // Sleep Out
	Delay_ms(120);
	 
	GP_COMMAD_PA(1),   
	SPI_WriteData(0x29); // Display ON 
	Delay_ms(50);
	 
	GP_COMMAD_PA(1);
	SPI_WriteData(0x21); // Display Inversion ON
	
	
	GP_COMMAD_PA(5);
	SPI_WriteData(0x2A); // Column Address Set
	SPI_WriteData(0x00);   
	SPI_WriteData(0x00); 
	SPI_WriteData(0x01); 
	SPI_WriteData(0x3F); 
	 
	GP_COMMAD_PA(5);
	SPI_WriteData(0x2B); // Row Address Set
	SPI_WriteData(0x00);   
	SPI_WriteData(0x00); 
	SPI_WriteData(0x01); 
	SPI_WriteData(0x3F);