找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1169|回复: 1
收起左侧

ST7735驱动程序

[复制链接]
ID:978854 发表于 2022-9-19 14:55 | 显示全部楼层 |阅读模式
51hei图片_20220919145426.jpg

单片机源程序如下:
  1. void ST7735S_init(void)
  2. {
  3.     /* ST7735R Reset Sequence */
  4.     LCD_RST_HIGH;
  5.     delay(5);           //Delay 1ms
  6.     LCD_RST_LOW;
  7.     delay(5);           //Delay 1ms
  8.     LCD_RST_HIGH;
  9.     delay(120);           //Delay 120ms
  10.     /* End ST7735S Reset Sequence */
  11.            Lcd_WriteCmd(0x01);    //SWRESET Software reset
  12.     delay(130);  
  13.     Lcd_WriteCmd(0x11);    //Sleep out
  14.     delay(130);                          //Delay 120ms
  15.     /* ST7735S Frame rate */
  16.     Lcd_WriteCmd(0xB1);    //Frame rate 80Hz
  17.     Lcd_WriteData(0x05);
  18.     Lcd_WriteData(0x3C);
  19.     Lcd_WriteData(0x3C);
  20.     Lcd_WriteCmd(0xB2);    //Frame rate 80Hz
  21.     Lcd_WriteData(0x05);
  22.     Lcd_WriteData(0x3C);
  23.     Lcd_WriteData(0x3C);
  24.     Lcd_WriteCmd(0xB3);    //Frame rate 80Hz
  25.     Lcd_WriteData(0x05);
  26.     Lcd_WriteData(0x3C);
  27.     Lcd_WriteData(0x3C);
  28.     Lcd_WriteData(0x05);
  29.     Lcd_WriteData(0x3C);
  30.     Lcd_WriteData(0x3C);
  31.     /* End ST7735S Frame rate */
  32.     Lcd_WriteCmd(0xB4);            //Dot inversion
  33.     Lcd_WriteData(0x03);
  34.     /* ST7735S Power Sequence */
  35.     Lcd_WriteCmd(0xC0);                   //Power control 1
  36.     Lcd_WriteData(0xA2);           //AVDD=5,GVDD=4.6
  37.     Lcd_WriteData(0x02);           //GVCL=-4.6
  38.     Lcd_WriteData(0x84);           //AUTO,VRHN5=0,VRHP5=0
  39.     Lcd_WriteCmd(0xC1);                   //Power control 2
  40.     Lcd_WriteData(0xC5);           //V25=2.4,VGL=-10,VGH=3*AVDD-0.5
  41.     Lcd_WriteCmd(0xC2);                   //Power control 3
  42.     Lcd_WriteData(0x0D);           //Large current,Small current
  43.     Lcd_WriteData(0x00);
  44.     Lcd_WriteCmd(0xC3);                   //Power control 4
  45.     Lcd_WriteData(0x8D);           //
  46.     Lcd_WriteData(0x2A);
  47.     Lcd_WriteCmd(0xC4);                   //Power control 5
  48.     Lcd_WriteData(0x8D);
  49.     Lcd_WriteData(0xEE);
  50.     /* End ST7735S Power Sequence */
  51.     Lcd_WriteCmd(0xC5);            //VCOM
  52.     Lcd_WriteData(0x0a);           //VCOM=-0.675
  53.     Lcd_WriteCmd(0x36);            //MX, MY, RGB mode; 控制显示方向
  54.     Lcd_WriteData(0xC0);           //0xC8 LCD refresh Top to Bottom, Left to right
  55.     /* ST7735S Gamma Sequence */
  56.     Lcd_WriteCmd(0xE0);
  57.     Lcd_WriteData(0x12);
  58.     Lcd_WriteData(0x1C);
  59.     Lcd_WriteData(0x10);
  60.     Lcd_WriteData(0x18);
  61.     Lcd_WriteData(0x33);
  62.     Lcd_WriteData(0x2C);
  63.     Lcd_WriteData(0x25);
  64.     Lcd_WriteData(0x28);
  65.     Lcd_WriteData(0x28);
  66.     Lcd_WriteData(0x27);
  67.     Lcd_WriteData(0x2F);
  68.     Lcd_WriteData(0x3C);
  69.     Lcd_WriteData(0x00);
  70.     Lcd_WriteData(0x03);
  71.     Lcd_WriteData(0x03);
  72.     Lcd_WriteData(0x10);

  73.     Lcd_WriteCmd(0xE1);
  74.     Lcd_WriteData(0x12);
  75.     Lcd_WriteData(0x1C);
  76.     Lcd_WriteData(0x10);
  77.     Lcd_WriteData(0x18);
  78.     Lcd_WriteData(0x2D);
  79.     Lcd_WriteData(0x28);
  80.     Lcd_WriteData(0x23);
  81.     Lcd_WriteData(0x28);
  82.     Lcd_WriteData(0x28);
  83.     Lcd_WriteData(0x26);
  84.     Lcd_WriteData(0x2F);
  85.     Lcd_WriteData(0x3B);
  86.     Lcd_WriteData(0x00);
  87.     Lcd_WriteData(0x03);
  88.     Lcd_WriteData(0x03);
  89.     Lcd_WriteData(0x10);

  90.            Lcd_WriteCmd(0x2A);        //设置列地址
  91.            Lcd_WriteData(0x00);
  92.            Lcd_WriteData(0x00);
  93.            Lcd_WriteData(0x00);
  94.            Lcd_WriteData(0x7F);//128

  95.            Lcd_WriteCmd(0x2B);        //设置行地址
  96.            Lcd_WriteData(0x00);
  97.            Lcd_WriteData(0x00);
  98.            Lcd_WriteData(0x00);
  99.            Lcd_WriteData(0x9F);//160

  100.            Lcd_WriteCmd(0xF0);        //Enable test command
  101.            Lcd_WriteData(0x01);
  102.            Lcd_WriteCmd(0xF6);        //Disable ram power save mode
  103.            Lcd_WriteData(0x00);
  104.          
  105.     /* End ST7735S Gamma Sequence */
  106.     Lcd_WriteCmd(0x3A); //65k mode
  107.     Lcd_WriteData(0x05);
  108.     Lcd_WriteCmd(0x29); //Display on
  109.            Lcd_WriteCmd(0x2c);
  110.            delay(50);
  111. }
复制代码

评分

参与人数 1黑币 +50 收起 理由
admin + 50

查看全部评分

回复

使用道具 举报

ID:978854 发表于 2022-9-19 14:59 | 显示全部楼层
这是近期做的一个项目中的TFT显示部分,用的是1.77寸的屏,驱动芯片是st7735。4线SPI接口,单片机模拟驱动时序
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表