使用MSP430驱动HX8340 TFT液晶屏

来源:本站
导读:目前正在解读《使用MSP430驱动HX8340 TFT液晶屏》的相关信息,《使用MSP430驱动HX8340 TFT液晶屏》是由用户自行发布的知识型内容!下面请观看由(电工技术网 - www.9ddd.net)用户发布《使用MSP430驱动HX8340 TFT液晶屏》的详细说明。

#include#define uint unsigned int#define uchar unsigned char#define LCD_RD_SET {P2OUT |= BIT0;}#define LCD_RD_CLR {P2OUT &= ~BIT0;}#define LCD_WR_SET {P2OUT |= BIT1;}#define LCD_WR_CLR {P2OUT &= ~BIT1;}#define LCD_RS_SET {P2OUT |= BIT2;}#define LCD_RS_CLR {P2OUT &= ~BIT2;}#define LCD_CS_SET {P2OUT |= BIT3;}#define LCD_CS_CLR {P2OUT &= ~BIT3;}#define LCD_RESET_SET {P2OUT |= BIT5;}#define LCD_RESET_CLR {P2OUT &= ~BIT5;}#defineLCD_DataPortH P1OUT //高8位数据口/*程序默认IO连接方式:DB0-DB7 P1OUTRD P2OUT.0WR P2OUT.1RS P2OUT.2CS P2OUT.3RESET P2OUT.5*/void delayms(uint count)// /* X1ms */{ uint i,j; for(i=0;i<count;i++) for(j=0;j<100;j++);}void Lcd_Write_Com( uintDH) //命令{ LCD_RS_CLR LCD_CS_CLR LCD_DataPortH=DH>>8; LCD_WR_CLR LCD_WR_SET LCD_DataPortH=DH; LCD_WR_CLR LCD_WR_SET LCD_CS_SET }void lcd_write_color(uchar hh,uchar ll) //发送颜色数据为提高速度高8位低8位分别传递 { LCD_RS_SET LCD_CS_CLR LCD_DataPortH=hh; LCD_WR_CLR LCD_WR_SET LCD_DataPortH=ll; LCD_WR_CLR LCD_WR_SET LCD_CS_SET }void Lcd_Write_Data(uint DH) //数据 { LCD_RS_SET LCD_CS_CLR LCD_DataPortH=DH>>8; LCD_WR_CLR LCD_WR_SET LCD_DataPortH=DH; LCD_WR_CLR LCD_WR_SET LCD_CS_SET }void Lcd_Write_Com_Data( uint com1,uint dat1) //命令数据一起{ Lcd_Write_Com(com1); Lcd_Write_Data(dat1);}void Address_set(uint x1,uint y1,uint x2,uint y2){Lcd_Write_Com_Data(0x0002,0x0000);Lcd_Write_Com_Data(0x0003,x1);Lcd_Write_Com_Data(0x0004,0x0000);Lcd_Write_Com_Data(0x0005,x2); Lcd_Write_Com_Data(0x0006,0x0000);Lcd_Write_Com_Data(0x0007,y1);Lcd_Write_Com_Data(0x0008,0x0000);Lcd_Write_Com_Data(0x0009,y2);Lcd_Write_Com (0x22);//LCD_WriteCMD(GRAMWR); } void TFT_init(void){ LCD_RESET_SET delayms(5); LCD_RESET_CLR delayms(10); LCD_RESET_SET LCD_CS_SET LCD_RD_SET LCD_WR_SET delayms(20); Lcd_Write_Com_Data(0x0026,0x0084); //PT=10,GON=0, DTE=0, D=0100 delayms(40); Lcd_Write_Com_Data(0x0026,0x00B8); //PT=10,GON=1, DTE=1, D=1000 delayms(40); Lcd_Write_Com_Data(0x0026,0x00BC); //PT=10,GON=1, DTE=1, D=1100 delayms(20); //新增加的延时080421 // Lcd_Write_Com_Data(0x0001,0x0000); // PTL='1' Enter Partail mode //Driving ability Setting Lcd_Write_Com_Data(0x0060,0x0000); //PTBA[15:8] Lcd_Write_Com_Data(0x0061,0x0006); //PTBA[7:0] Lcd_Write_Com_Data(0x0062,0x0000); //STBA[15:8] Lcd_Write_Com_Data(0x0063,0x00C8); //STBA[7:0] delayms(20); //新增加的延时 080421 //Gamma Setting Lcd_Write_Com_Data(0x0073,0x0070); // Lcd_Write_Com_Data(0x0040,0x0000); // Lcd_Write_Com_Data(0x0041,0x0040); // Lcd_Write_Com_Data(0x0042,0x0045); // Lcd_Write_Com_Data(0x0043,0x0001); // Lcd_Write_Com_Data(0x0044,0x0060); // Lcd_Write_Com_Data(0x0045,0x0005); // Lcd_Write_Com_Data(0x0046,0x000C); // Lcd_Write_Com_Data(0x0047,0x00D1); // Lcd_Write_Com_Data(0x0048,0x0005); // Lcd_Write_Com_Data(0x0050,0x0075); // Lcd_Write_Com_Data(0x0051,0x0001); // Lcd_Write_Com_Data(0x0052,0x0067); // Lcd_Write_Com_Data(0x0053,0x0014); // Lcd_Write_Com_Data(0x0054,0x00F2); // Lcd_Write_Com_Data(0x0055,0x0007); // Lcd_Write_Com_Data(0x0056,0x0003); // Lcd_Write_Com_Data(0x0057,0x0049); // delayms(20); //新增加的延时 080421 //Power Setting Lcd_Write_Com_Data(0x001F,0x0003); //VRH=4.65V VREG1(GAMMA) 00~1E080421 Lcd_Write_Com_Data(0x0020,0x0000); //BT (VGH~15V,VGL~-12V,DDVDH~5V) Lcd_Write_Com_Data(0x0024,0x0024); //VCOMH(VCOM High voltage3.2V) 0024/12 080421 11~40 Lcd_Write_Com_Data(0x0025,0x0034); //VCOML(VCOM Low voltage -1.2V) 0034/4A 080421 29~3F //****VCOM offset**/// Lcd_Write_Com_Data(0x0023,0x002F); //VMF(no offset) delayms(20); //新增加的延时080421 10~39 //################################################################## // Power Supply Setting Lcd_Write_Com_Data(0x0018,0x0044); //I/P_RADJ,N/P_RADJ Noraml mode 60Hz Lcd_Write_Com_Data(0x0021,0x0001); //OSC_EN='1' start osc Lcd_Write_Com_Data(0x0001,0x0000); //SLP='0' out sleep Lcd_Write_Com_Data(0x001C,0x0003); //AP=011 Lcd_Write_Com_Data(0x0019,0x0006); // VOMG=1,PON=1, DK=0, delayms(20); //新增加的延时080421 //################################################################## // Display ON Setting Lcd_Write_Com_Data(0x0026,0x0084); //PT=10,GON=0, DTE=0, D=0100 delayms(40); Lcd_Write_Com_Data(0x0026,0x00B8); //PT=10,GON=1, DTE=1, D=1000 delayms(40); Lcd_Write_Com_Data(0x0026,0x00BC); //PT=10,GON=1, DTE=1, D=1100 delayms(20); //新增加的延时080421 //SET GRAM AREA Lcd_Write_Com_Data(0x0002,0x0000); Lcd_Write_Com_Data(0x0003,0x0000); Lcd_Write_Com_Data(0x0004,0x0000); Lcd_Write_Com_Data(0x0005,0x00AF); Lcd_Write_Com_Data(0x0006,0x0000); Lcd_Write_Com_Data(0x0007,0x0000); Lcd_Write_Com_Data(0x0008,0x0000); Lcd_Write_Com_Data(0x0009,0x00DB); delayms(20); //新增加的延时080421 Lcd_Write_Com_Data(0x0016,0x0008);//MV MX MY ML SET0028横屏显示(此时Lcd_Write_Com_Data(0x0005,0x00DB);Lcd_Write_Com_Data(0x0009,0x00AF);) Lcd_Write_Com_Data(0x0017,0x0005);//COLMOD Control Register (R17h) Lcd_Write_Com (0x0021);//LCD_WriteCMD(GRAMWR) Lcd_Write_Com(0x0022);}void Pant(uint color){ uint i,j; Address_set(0,0,175,219); for(i=0;i<220;i++) { for (j=0;j<176;j++) { Lcd_Write_Data(color); } } }void main(){ WDTCTL=WDTPW+WDTHOLD;//关看门狗 BCSCTL1 = CALBC1_8MHZ; // Set DCO DCOCTL = CALDCO_8MHZ;// BCSCTL2=SELM_3;//选择时钟源为MCLK P1SEL&=0x00;//P1为I/O模式 P1DIR|=0xff;//选择P1为输出端 P2DIR|=0xff;//P2为输出端 P1OUT = 0x00; P2OUT = 0x00; TFT_init(); //tft初始化 while(1) { Pant(0xf800); //红色 Pant(0X07E0); //绿色 Pant(0x001f); //蓝色 Pant(0xffff); //清屏 } }

提醒:《使用MSP430驱动HX8340 TFT液晶屏》最后刷新时间 2024-03-14 01:22:44,本站为公益型个人网站,仅供个人学习和记录信息,不进行任何商业性质的盈利。如果内容、图片资源失效或内容涉及侵权,请反馈至,我们会及时处理。本站只保证内容的可读性,无法保证真实性,《使用MSP430驱动HX8340 TFT液晶屏》该内容的真实性请自行鉴别。