hx8347驱动0.docx
- 文档编号:11663237
- 上传时间:2023-03-29
- 格式:DOCX
- 页数:45
- 大小:25.88KB
hx8347驱动0.docx
《hx8347驱动0.docx》由会员分享,可在线阅读,更多相关《hx8347驱动0.docx(45页珍藏版)》请在冰豆网上搜索。
hx8347驱动0
1.//////////2.8////////////////
2.void INITIAL_HX8347(void)
3.{
4.//##########################################################################
5.//Gamma Set:
6.
7. Set_LCD_8B_REG(0x46,0x95); //
8. Set_LCD_8B_REG(0x47,0x51); //
9. Set_LCD_8B_REG(0x48,0x00); //
10. Set_LCD_8B_REG(0x49,0x36); //
11. Set_LCD_8B_REG(0x4A,0x11); //
12. Set_LCD_8B_REG(0x4B,0x66); //
13. Set_LCD_8B_REG(0x4C,0x14); //
14. Set_LCD_8B_REG(0x4D,0x77); //
15. Set_LCD_8B_REG(0x4E,0x13); //
16. Set_LCD_8B_REG(0x4F,0x4C); //
17. Set_LCD_8B_REG(0x50,0x46); //
18. Set_LCD_8B_REG(0x51,0x46); //
19.//##########################################################################
20.//240x320 window setting:
21.
22. Set_LCD_8B_REG(0x02,0x00); // Column address start2
23. Set_LCD_8B_REG(0x03,0x00); // Column address start1
24.
25. Set_LCD_8B_REG(0x04,0x00); // Column address end2
26. Set_LCD_8B_REG(0x05,0xEF); // Column address end1
27.
28. Set_LCD_8B_REG(0x06,0x00); // Row address start2
29. Set_LCD_8B_REG(0x07,0x00); // Row address start1
30.
31. Set_LCD_8B_REG(0x08,0x01); // Row address end2
32. Set_LCD_8B_REG(0x09,0x3F); // Row address end1
33.
34. Set_LCD_8B_REG(0x90,0x7F); // SAP=0111 1111
35.//##########################################################################
36.// Display Setting:
37.
38. Set_LCD_8B_REG(0x01,0x06); // IDMON=0, INVON=1, NORON=1, PTLON=0
39.
40. Set_LCD_8B_REG(0x16,0xC8); //MY, MX, MV, ML, BGR, TEON
41.
42. Set_LCD_8B_REG(0x23,0x95); // N_DC=1001 0101
43. Set_LCD_8B_REG(0x24,0x95); // P_DC=1001 0101
44. Set_LCD_8B_REG(0x25,0xFF); // I_DC=1111 1111
45.
46. Set_LCD_8B_REG(0x27,0x06); // N_BP=0000 0110
47. Set_LCD_8B_REG(0x28,0x06); // N_FP=0000 0110
48. Set_LCD_8B_REG(0x29,0x06); // P_BP=0000 0110
49. Set_LCD_8B_REG(0x2A,0x06); // P_FP=0000 0110
50. Set_LCD_8B_REG(0x2C,0x06); // I_BP=0000 0110
51. Set_LCD_8B_REG(0x2D,0x06); // I_FP=0000 0110
52.
53. Set_LCD_8B_REG(0x3A,0x01); // N_RTN=0000, N_NW=001
54. Set_LCD_8B_REG(0x3B,0x01); // P_RTN=0000, P_NW=001
55. Set_LCD_8B_REG(0x3C,0xF0); // I_RTN=1111, I_NW=000
56. Set_LCD_8B_REG(0x3D,0x00); // DIV=00
57. DelayX1ms(20);
58.
59. Set_LCD_8B_REG(0x10,0xA6); // SS=0,GS=0 CSEL=110
60.//##########################################################################
61.// Power Supply Setting
62.
63. Set_LCD_8B_REG(0x19,0x49); // OSCADJ=10 0000, OSD_EN=1 //60Hz
64. Set_LCD_8B_REG(0x93,0x0C); // RADJ=1100,
65. DelayX1ms(10);
66.
67. Set_LCD_8B_REG(0x20,0x40); // BT=0100
68.
69. Set_LCD_8B_REG(0x1D,0x07); // VC1=111
70. Set_LCD_8B_REG(0x1E,0x00); // VC3=000
71. Set_LCD_8B_REG(0x1F,0x04); // VRH=0100
72.
73. Set_LCD_8B_REG(0x44,0x4D); // VCM=101 0000
74. Set_LCD_8B_REG(0x45,0x11); // VDV=1 0001
75. DelayX1ms(10);
76.
77. Set_LCD_8B_REG(0x1C,0x04); // AP=100
78. DelayX1ms(20);
79. Set_LCD_8B_REG(0x43,0x80); //set VCOMG=1
80. DelayX1ms(5);
81. Set_LCD_8B_REG(0x1B,0x18); // GASENB=0, PON=1, DK=1, XDK=0, DDVDH_TRI=0, STB=0
82. DelayX1ms(40);
83.
84. Set_LCD_8B_REG(0x1B,0x10); // GASENB=0, PON=1, DK=0, XDK=0, DDVDH_TRI=0, STB=0
85. DelayX1ms(40);
86.//##########################################################################
87.// Display ON Setting
88.
89. Set_LCD_8B_REG(0x26,0x04); //GON=0, DTE=0, D=01
90. DelayX1ms(40);
91. Set_LCD_8B_REG(0x26,0x24); //GON=1, DTE=0, D=01
92. Set_LCD_8B_REG(0x26,0x2C); //GON=1, DTE=0, D=11
93. DelayX1ms(40);
94.
95. Set_LCD_8B_REG(0x26,0x3C); //GON=1, DTE=1, D=11
96.
97. Set_LCD_8B_REG(0x35,0x38); // EQS=38h
98. Set_LCD_8B_REG(0x36,0x78); // EQP=78h
99.
100. Set_LCD_8B_REG(0x3E,0x38); // SON=38h
101.
102. Set_LCD_8B_REG(0x40,0x0F); // GDON=0Fh
103. Set_LCD_8B_REG(0x41,0xF0); // GDOFF
104.//##########################################################################
105.//set spulse & rpulse
106. Set_LCD_8B_REG(0x57,0x02); // Test mode='1'
107. Set_LCD_8B_REG(0x56,0x84); // set Rpulse='1000',spulse='0100'
108. Set_LCD_8B_REG(0x57,0x00); // Test mode= '0'
109.//##########################################################################
110.}
111.void Set_LCD_8B_REG(uchar reg,uchar dat)
112.{
113. rd=1;
114. rs=0;
115. dataport=reg;
116. cs=0;
117. wr=0;
118. _nop_();
119. wr=1;
120. rs=1;
121. dataport=dat;
122. wr=0;
123. _nop_();
124. wr=1;
125. cs=1;
126.}
1./*********************************************************
2. Controller:
HX8347D
3. Panel:
CMO2.2
4. Reslution:
5. VDD:
2.8v
6. Interface:
8080--16bit/1-8 10-17
7. Dataport:
P2 -->DB8-DB15
8. P0 -->DB0-DB7
9.*********************************************************/
10.
11.#include"reg51.h"
12.#include
13.#include
14.#define CtrPort P3
15.sbit P10 =P1^0;
16.sbit P11 =P1^1;
17.sbit P12 =P1^2;
18.sbit P13 =P1^3;
19.sbit P14 =P1^4;
20.sbit P16 =P1^6;
21.sbit P17 =P1^7;
22.//sbit Ram_chip_select1 =P1^4;
23.sbit Ram_chip_select2 =P1^5;
24.//sbit Ram_chip_select3 =P1^3;
25.//unsigned char code pic[];
26.const
27.// /RESET /CS /RD /WR /RS
28.cwrite =0xf4; // 1 0 1 0 0
29.cwrite_set =0xf6; // 1 0 1 1 0
30.dwrite =0xf5; // 1 0 1 0 1
31.dwrite_set =0xf7; // 1 0 1 1 1
32.
33./**********************************************************/
34.void delay(unsigned int para)
35.{
36. for(;para;para--);
37.}
38.
39.void LCD_Index_Out(unsigned char Index)
40.{
41. CtrPort=cwrite_set;
42. P2=0x00;
43. P0=Index;
44.
45. CtrPort=cwrite;
46. CtrPort=cwrite_set;
47.}
48.
49.void LCD_Data_Out(unsigned char set_dbH,unsigned char set_dbL)
50.{
51. P2=set_dbH;
52. P0=set_dbL;
53.
54. CtrPort=dwrite;
55. CtrPort=dwrite_set;
56.}
57.
58.void control_out(unsigned char x,unsigned char y)
59.{
60. unsigned char m,n;
61. m=y>>8;
62. n=y;
63. LCD_Index_Out(x);
64. LCD_Data_Out(m,n);
65.}
66.
67.void LCD_Data_Out1(unsigned int y)
68.{
69. unsigned char m,n;
70. m=y>>8;
71. n=y;
72. LCD_Data_Out(m,n);
73.}
74.
75.
76.void RESET(void)
77.{
78. CtrPort=0xff;
79. delay(50);
80. CtrPort=0xef;
81. delay(300);
82. CtrPort=0xff;
83. delay(150);
84.}
85.
86.void MainAddset()
87.{
88.LCD_Index_Out(0x20);
89.LCD_Data_Out(0x00,0x00);
90.
91.LCD_Index_Out(0x21);
92.LCD_Data_Out(0x00,0x00);
93.
94.LCD_Index_Out(0x22);
95.}
96.
97.void Init_LCD(void)
98.{
99. RESET();
100.delay(150); // After Inter-MicroP Program (load OTP)
101.control_out(0x00EA,0x0000); //PTBA[15:
8]
102.control_out(0x00EB,0x0020); //PTBA[7:
0]
103.control_out(0x00EC,0x000C); //STBA[15:
8]
104.control_out(0x00ED,0x00C4); //STBA[7:
0]
105.control_out(0x00E8,0x0040); //OPON[7:
0]
106.control_out(0x00E9,0x0038); //OPON1[7:
0]
107.control_out(0x00F1,0x0001); //OTPS1B
108.control_out(0x00F2,0x0010); //GEN
109.control_out(0x0027,0x00A3); //
110.//Gamma 2.2 Setting
111.control_out(0x0040,0x0000); //
112.control_out(0x0041,0x0000); //
113.control_out(0x0042,0x0001); //
114.control_out(0x0043,0x0012); //
115.control_out(0x0044,0x0010); //
116.control_out(0x0045,0x0026); //
117.control_out(0x0046,0x0008); //
118.control_out(0x0047,0x0053); //
119.control_out(0x0048,0x0002); //
120.control_out(0x0049,0x0015); //
121.control_out(0x004A,0x0019); //
122.control_out(0x004B,0x0019); //
123.control_out(0x004C,0x0016); //
124.control_out(0x0050,0x0019); //
125.control_out(0x0051,0x002F); //
126.control_out(0x0052,0x002D); //
127.control_out(0x0053,0x003E); //
128.control_out(0x0054,0x003F); //
129.control_out(0x0055,0x003F); //
130.control_out(0x0056,0x002C); //
131.control_out(0x0057,0x0077); //
132.control_out(0x0058,0x0009); //
1
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- hx8347 驱动