楼主
基于NV32F100开发板的2.2' TFT屏显示驱动
470
0
发表于 2023-6-17 22:49:47
2.2' TFT屏是一款彩色TFT显示屏,可用于信息显示及图形绘制等。 在合理配置引脚使用的情况下,可驱动TFT显示屏。为此使TFT显示屏与NV32F100建立如下的连接关系: CS --- PD1 REST--- PH1DC --- P H0SDI --- PE0SCK --- PE1为驱动TFT显示屏使相关引脚输出高低电平的语句为:#define LCD_CS_High() GPIO_PinSet(GPIO_PTD1);#define LCD_CS_Low() GPIO_PinClear(GPIO_PTD1);#define LCD_REST_High() GPIO_PinSet(GPIO_PTH1);#define LCD_REST_Low() GPIO_PinClear(GPIO_PTH1);#define LCD_DC_High() GPIO_PinSet(GPIO_PTH0);#define LCD_DC_Low() GPIO_PinClear(GPIO_PTH0);#define LCD_SDI_High() GPIO_PinSet(GPIO_PTE0);#define LCD_SDI_Low() GPIO_PinClear(GPIO_PTE0);#define LCD_SCK_High() GPIO_PinSet(GPIO_PTE1);#define LCD_SCK_Low() GPIO_PinClear(GPIO_PTE1);复制代码
相关引脚的配置函数为: void GPIO_Configuration(void) {GPIO_Init(GPIOB, GPIO_PTE0_MASK, GPIO_PinOutput);GPIO_Init(GPIOB, GPIO_PTE1_MASK, GPIO_PinOutput); GPIO_Init(GPIOB,GPIO_PTH0_MASK, GPIO_PinOutput);GPIO_Init(GPIOB, GPIO_PTH1_MASK, GPIO_PinOutput); GPIO_Init(GPIOA,GPIO_PTD1_MASK, GPIO_PinOutput);}复制代码
进行TFT显示屏初始化的函数为: void Lcd_Init(void) { LCD_REST_Low(); delay_ms(20); LCD_REST_High(); delay_ms(20); LCD_CS_Low(); LCD_WR_REG(0xCB); LCD_WR_DATA8(0x39); LCD_WR_DATA8(0x2C); LCD_WR_DATA8(0x00); LCD_WR_DATA8(0x34); LCD_WR_DATA8(0x02); LCD_WR_REG(0xCF); LCD_WR_DATA8(0x00); LCD_WR_DATA8(0XC1); LCD_WR_DATA8(0X30); LCD_WR_REG(0xE8); LCD_WR_DATA8(0x85); LCD_WR_DATA8(0x00); LCD_WR_DATA8(0x78); LCD_WR_REG(0xEA); LCD_WR_DATA8(0x00); LCD_WR_DATA8(0x00); LCD_WR_REG(0xED); LCD_WR_DATA8(0x64); LCD_WR_DATA8(0x03); LCD_WR_DATA8(0X12); LCD_WR_DATA8(0X81); LCD_WR_REG(0xF7); LCD_WR_DATA8(0x20); LCD_WR_REG(0xC0); //Power control LCD_WR_DATA8(0x23); //VRH[5:0] LCD_WR_REG(0xC1); //Power control LCD_WR_DATA8(0x10); //SAP[2:0];BT[3:0] LCD_WR_REG(0xC5); //VCM control LCD_WR_DATA8(0x3e); LCD_WR_DATA8(0x28); LCD_WR_REG(0xC7); //VCM control2 LCD_WR_DATA8(0x86); LCD_WR_REG(0x36); // Memory Access Control LCD_WR_DATA8(0x48); //C8 LCD_WR_REG(0x3A); LCD_WR_DATA8(0x55); LCD_WR_REG(0xB1); LCD_WR_DATA8(0x00); LCD_WR_DATA8(0x18); LCD_WR_REG(0xB6); // Display Function Control LCD_WR_DATA8(0x08); LCD_WR_DATA8(0x82); LCD_WR_DATA8(0x27); LCD_WR_REG(0xF2); // 3Gamma Function Disable LCD_WR_DATA8(0x00); LCD_WR_REG(0x26); //Gamma curve selected LCD_WR_DATA8(0x01); LCD_WR_REG(0xE0); //Set Gamma LCD_WR_DATA8(0x0F); LCD_WR_DATA8(0x31); LCD_WR_DATA8(0x2B); LCD_WR_DATA8(0x0C); LCD_WR_DATA8(0x0E); LCD_WR_DATA8(0x08); LCD_WR_DATA8(0x4E); LCD_WR_DATA8(0xF1); LCD_WR_DATA8(0x37); LCD_WR_DATA8(0x07); LCD_WR_DATA8(0x10); LCD_WR_DATA8(0x03); LCD_WR_DATA8(0x0E); LCD_WR_DATA8(0x09); LCD_WR_DATA8(0x00); LCD_WR_REG(0XE1); //Set Gamma LCD_WR_DATA8(0x00); LCD_WR_DATA8(0x0E); LCD_WR_DATA8(0x14); LCD_WR_DATA8(0x03); LCD_WR_DATA8(0x11); LCD_WR_DATA8(0x07); LCD_WR_DATA8(0x31); LCD_WR_DATA8(0xC1); LCD_WR_DATA8(0x48); LCD_WR_DATA8(0x08); LCD_WR_DATA8(0x0F); LCD_WR_DATA8(0x0C); LCD_WR_DATA8(0x31); LCD_WR_DATA8(0x36); LCD_WR_DATA8(0x0F); LCD_WR_REG(0x11); //Exit Sleep delay_ms(120); LCD_WR_REG(0x29); //Display on LCD_WR_REG(0x2c);}复制代码[size=13.3333px]以色彩擦除屏幕的函数为: void LCD_Clear(uint16_t Color) { char VH,VL; uint16_t i,j; VH=Color>>8; VL=Color; Address_set(0,0,LCD_W-1,LCD_H-1); for(i=0;i<LCD_W;i++) { for (j=0;j<LCD_H;j++) { LCD_WR_DATA8(VH); LCD_WR_DATA8(VL); } }}复制代码字符串 中文
|