微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > ATmega16L驱动ILI9325/9328

ATmega16L驱动ILI9325/9328

时间:11-20 来源:互联网 点击:

  1. LCD_DATA_PORT=regID>>A_PORT=regID>>8;
  2. LCD_WR_L;
  3. LCD_WR_H;
  4. LCD_DATA_PORT=regID;
  5. LCD_WR_L;
  6. LCD_WR_H;
  7. LCD_RS_H;
  8. LCD_DATA_PORT=regData>>8;
  9. LCD_WR_L;
  10. LCD_WR_H;
  11. LCD_DATA_PORT=regData;
  12. LCD_WR_L;
  13. LCD_WR_H;
  14. }
  15. /*********************************************************************************************************
  16. **Functionname:LCD_ReadReg
  17. **Descriptions:读取指定寄存器的数据
  18. **inputparameters:寄存器地址:regID
  19. **outputparameters:无
  20. **Returnedvalue:读出数据(16位)
  21. *********************************************************************************************************/
  22. ////////////////////////////////////////////////////////////////////////////////////////////////////
  23. //nCS----\_____________________________________________________________/--------//
  24. //RS----\____________________________/-----------------------------------------//
  25. //nRD-----------------------------------\_____/------\_____/------------------//
  26. //nWR------\______/--------\_____/----------------------------------------------//
  27. //DB[10:17]---[寄存器高8位]--[寄存器低8位]--[数据高8位]--[数据低8位]---------------//
  28. /////////////////////////////////////////////////////////////////////////////////////////////////////
  29. unsignedintLCD_ReadReg(uint32regID)
  30. {
  31. uint32regData;
  32. LCD_WriteCmd(regID);
  33. LCD_DATA_IN;
  34. LCD_RS_H;
  35. LCD_RD_L;
  36. LCD_RD_H;
  37. regData=LCD_DATA_PIN;
  38. regData=regData<8;
  39. LCD_RD_L;
  40. LCD_RD_H;
  41. regData|=LCD_DATA_PIN;
  42. LCD_WR_L;
  43. LCD_WR_H;
  44. LCD_DATA_OUT;
  45. returnregData;
  46. }
  47. /*********************************************************************************************************
  48. **Functionname:LCD_ILI9325_Init
  49. **Descriptions:9325/28内部寄存器的初始化
  50. **inputparameters:无
  51. **outputparameters:无
  52. **Returnedvalue:无
  53. *********************************************************************************************************/
  54. voidLCD_ILI9325_Init(void)
  55. {
  56. uint32ID=0x0000;
  57. LCD_Port_Init();
  58. LCD_REST_L;//复位
  59. Delay_nMS(50);
  60. LCD_REST_H;
  61. Delay_nMS(50);
  62. LCD_SELECT();
  63. ID=LCD_ReadReg(0x0000);//读LCD的ID,这里是9328
  64. Uart_Transmit(ID>>8);//串口观察
  65. Uart_Transmit(ID);
  66. LCD_WriteReg(0x0001,0x0100);
  67. LCD_WriteReg(0x0002,0x0700);
  68. LCD_WriteReg(0x0003,0x1030);//转换RGB至GBR,水平扫描
  69. LCD_WriteReg(0x0004,0x0000);
  70. LCD_WriteReg(0x0008,0x0207);
  71. LCD_WriteReg(0x0009,0x0000);
  72. LCD_WriteReg(0x000A,0x0000);
  73. LCD_WriteReg(0x000C,0x0000);
  74. LCD_WriteReg(0x000D,0x0000);
  75. LCD_WriteReg(0x000F,0x0000);
  76. //poweronsequenceVGHVGL
  77. LCD_WriteReg(0x0010,0x0000);
  78. LCD_WriteReg(0x0011,0x0007);
  79. LCD_WriteReg(0x0012,0x0000);
  80. LCD_WriteReg(0x0013,0x0000);
  81. //vgh
  82. LCD_WriteReg(0x0010,0x1290);
  83. LCD_WriteReg(0x0011,0x0227);
  84. //vregiout
  85. LCD_WriteReg(0x0012,0x001d);//0x001b
  86. //vomamplitude
  87. LCD_WriteReg(0x0013,0x1500);
  88. //vomH
  89. LCD_WriteReg(0x0029,0x0018);
  90. LCD_WriteReg(0x002B,0x000D);
  91. //gamma
  92. LCD_WriteReg(0x0030,0x0004);
  93. LCD_WriteReg(0x0031,0x0307);
  94. LCD_WriteReg(0x0032,0x0002);//0006
  95. LCD_WriteReg(0x0035,0x0206);
  96. LCD_WriteReg(0x0036,0x0408);
  97. LCD_WriteReg(0x0037,0x0507);
  98. LCD_WriteReg(0x0038,0x0204);//0200
  99. LCD_WriteReg(0x0039,0x0707);
  100. LCD_WriteReg(0x003C,0x0405);//0504
  101. LCD_WriteReg(0x003D,0x0F02);
  102. //ram
  103. LCD_WriteReg(0x0050,0x0000);
  104. LCD_WriteReg(0x0051,0x00EF);
  105. LCD_WriteReg(0x0052,0x0000);
  106. LCD_WriteReg(0x0053,0x013F);
  107. LCD_WriteReg(0x0060,0xA700);
  108. LCD_WriteReg(0x0061,0x0001);
  109. LCD_WriteReg(0x006A,0x0000);
  110. //
  111. LCD_WriteReg(0x0080,0x0000);
  112. LCD_WriteReg(0x0081,0x0000);
  113. LCD_WriteReg(0x0082,0x0000);
  114. LCD_WriteReg(0x0083,0x0000);
  115. LCD_WriteReg(0x0084,0x0000);
  116. LCD_WriteReg(0x0085,0x0000);
  117. //
  118. LCD_WriteReg(0x0090,0x0010);
  119. LCD_WriteReg(0x0092,0x0600);
  120. LCD_WriteReg(0x0093,0x0003);
  121. LCD_WriteReg(0x0095,0x0110);
  122. LCD_WriteReg(0x0097,0x0000);
  123. LCD_WriteReg(0x0098,0x0000);
  124. LCD_WriteReg(0x0007,0x0133);
  125. LCD_DIS_SELECT();
  126. }
  127. /*********************************************************************************************************
  128. **Functionname:LCD

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top