|
本帖最后由 慕名而来 于 2022-7-14 10:24 编辑
最近在玩一块SPI接口的彩屏、480*320点ILI9481驱动,这块彩屏之前已经用STC15W408AS单片机I/O模拟SPI正常驱动成功了,想用ESP8266驱动就出现了问题,问题是不能全屏显示颜色,这个屏的SPI是在8位数据之前加了1位数据来代替标准4线SPI的RS(D/C)信号,也就是说他是一个9bit串口SPI发送的模式,常见的8位总线的硬件SPI是无法驱动的,数据手册上有一段话描述了其总线特征:
During the write sequence the host processor writes one or more bytes of information to the display module via
the interface. The write sequence is initiated when CSX is driven from high to low and ends when CSX is pulled
high. Each byte is either nine or sixteen write cycles in length. If the optional D/CX signal is used a byte is eight
write cycles long. D/CX is driven low while command information is on the interface and is pulled high when data
is present.
这是它的时序图:
我不懂鸟语,使用Google在线翻译,其中有一句为:“每个字节的长度为 9 或 16 个写周期。 如果使用可选的 D/CX 信号,则一个字节为 8个写周期”,由此看来它可以使用16位硬件SPI驱动的,通过ESP8266 arduino的16位SPI印证属实是可以驱动的,程序如下:
- //====写指令函数============================
- void write_command(uint8_t command)
- {
- uint16_t dat;
- dat=command;
- dat=(dat<<7)&0x7fff;//第一位是D/C指令、数据高位先行
- digitalWrite(cs,LOW);
- SPI.transfer16(dat);
- digitalWrite(cs,HIGH);
- }
复制代码
- //====写8位数据函数===========================
- void write_data(uint8_t tdata)
- {
- uint16_t dat;
- dat=tdata;
- dat=(dat<<7)|0x8000;
- digitalWrite(cs,LOW);
- SPI.transfer16(dat);
- digitalWrite(cs,HIGH);
- }
复制代码- //====写24位数据函数============================
- void lcd_wr_data(uint32_t da)
- {
- uint8_t temp1,temp2,temp3;
- temp1=(uint8_t)(da>>16);
- temp2=(uint8_t)(da>>8);
- temp3=(uint8_t)da;
- write_data(temp3);
- write_data(temp2);
- write_data(temp1);
- }
复制代码- //====LCD显示定位函数=========================
- void lcd_SetPos(uint16_t x0, uint16_t x1, uint16_t y0, uint16_t y1)
- {
- write_command(0x2A);
- write_data((uint8_t)(x0>>8));
- write_data((uint8_t)x0);
- write_data((uint8_t)(x1>>8));
- write_data((uint8_t)x1);
-
- write_command(0x2B);
- write_data((uint8_t)(y0>>8));
- write_data((uint8_t)y0);
- write_data((uint8_t)(y1>>8));
- write_data((uint8_t)y1);
- write_command(0x2c);
- }
- //====清空屏幕(屏幕显示单一颜色)函数===========
- void Show_RGB (uint16_t x0,uint16_t x1,uint16_t y0,uint16_t y1,uint32_t color)
- {
- unsigned int i,j;
- lcd_SetPos(x0,x1-1,y0,y1-1);
- for (i=y0;i<=y1;i++)
- {
- for (j=x0;j<=x1;j++)
- {lcd_wr_data(color);}
- }
- }
复制代码
上述代码横屏可以显示颜色但不正常!现象为只能显示110多行666(18bit)色点像素,不能拉满全屏,并且此后处于死机状态不再执行其他显示了。
为了验证是否是变量设置的值域问题,又做了竖条显示,现象为可以显示高度320宽度不超过220的矩形竖条。
接下来也进行了I/O模拟SPI驱动的测试,但仍然不能全屏显示,相必硬件SPI可以显示的面积有少了很多。
因为不熟悉arduino编程,想不明白这是什么问题,请各位遇到过此类问题的坛友指点一下,先谢了!
下图是ESP8266模拟SPI显示的图片,显示宽度应该在80线左右。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
|