当前位置:网站首页>3線spi屏幕驅動方式
3線spi屏幕驅動方式
2022-06-27 00:49:00 【NULL_1969】
前言
最近研究了一下3線spi屏幕的驅動方式。屏幕的驅動芯片為ILI9488,相比於4線,3線spi屏幕沒有用到DC寫命令/寫數據控制線。DC=0錶示寫命令,DC=1錶示寫數據。
3線spi數據格式

3線spi就是將DC命令放到了每個8比特數據的最高比特。這麼說還是有些枯燥,看下具體的例子。
假如采用spi發送0x55,一般采用的MSB,高比特在前的方式。
那麼SDA(MOSI)數據線上是這樣的:
01010101
如果要假如dc命令,則0x55要分為兩個字節進行發送,假設DC=1,則SDA(MOSI)數據如下:
10101010 1
低字節 高字節
相當於要將0x55轉換為:0x80AA。同時要在單片機中設置spi數據為9比特。經過多次摸索,其轉換公式為:
uint16_t data = (0x8000&(cmd<<15))|(0x7f&(cmd>>1)) ;
具體在esp32中需要將發送函數改為如下:
static void lcd_cmd(spi_device_handle_t spi, const uint8_t cmd)
{
esp_err_t ret;
spi_transaction_t t;
uint16_t data=0;
data = (0x8000&(cmd<<15))|(0x7f&(cmd>>1)) ;
memset(&t, 0, sizeof(t)); //Zero out the transaction
t.length=9; //Command is 8 bits
t.tx_buffer=&data; //The data is the cmd itself
ret=spi_device_polling_transmit(spi, &t); //Transmit!
assert(ret==ESP_OK); //Should have had no issues.
}
static void lcd_data_byte(spi_device_handle_t spi, const uint8_t cmd)
{
esp_err_t ret;
spi_transaction_t t;
uint16_t data=0;
data = (0x8000&(cmd<<15))|(0x80|cmd>>1) ;
memset(&t, 0, sizeof(t)); //Zero out the transaction
t.length=8; //Command is 8 bits
t.tx_buffer=&data; //The data is the cmd itself
ret=spi_device_polling_transmit(spi, &t); //Transmit!
assert(ret==ESP_OK); //Should have had no issues.
}
只有改成為這樣才能正常與屏幕通信。這個造成了通信速度降低,難以采用dma傳輸大量的數據。原因就是每個字節都要先進行拆解拼凑成2個字節再發送。及其不方便,當時調這個花了不少時間。
個人覺得3線spi通信方式及其扯淡,效率極低,還是老老實實用4線spi或者單片機8080接口來驅動屏幕。有的屏幕中DC引脚使用RS來錶示的,筆者也是一開始沒搞明白,發現這個屏幕沒有DC引脚,才來研究3線spi,後面發現屏幕刷新率太低了,刷新一整屏需要10s鐘。最後發現RS=DC,立刻改為4線spi,爽歪歪。
不過ILI9488這個驅動芯片最坑的一點是采用spi方式,只支持8bit和18bit的顏色格式,不支持16bit。這是實驗所得,其規格書上寫的是采用4線spi時,可以支持16bit顏色,
但將0x3A寫入0x05(16bit)屏幕沒有顯示,只有將0x3A寫入0x06(18bit)時,才能顯示出顏色。這一點非常坑爹。
ILI9488 18比特顏色格式

通常用的都是16比特顏色,所以在采用18比特顏色是需要進行裝換。然後再通過spi發送。具體轉換方式就是
colors[0] = (color>>8)&0xf8;
colors[1] = (color>>3)&0xfc;
colors[2] = (color<<3)&0xfc;
紅色放到第一個字節,綠色放到第二個字節,藍色放到低三個字節,且都是高比特對齊。低比特空置。轉換後屏幕即可正常顯示。
边栏推荐
- How to control the quality of HD slip ring in the production process
- Technical dry goods | top speed, top intelligence and minimalist mindspore Lite: help Huawei watch become more intelligent
- Is it safe to buy pension insurance online? Is there a policy?
- 玩转OLED,U8g2动画,增长数字和随机三角形等
- 全網最全的混合精度訓練原理
- Oracle 数据库基本知识概念
- Interface test framework practice (I) | requests and interface request construction
- 解决STC8G1K08程序不能运行的问题和端口配置
- Employment prospect of GIS and remote sensing specialty and ranking selection of universities in 2022
- Is it safe for CITIC Securities Commission to open an online account and speculate in stocks
猜你喜欢

Big guys talk about the experience sharing of the operation of the cutting-edge mindspore open source community. Come up with a small notebook!

ESP32-SOLO开发教程,解决CONFIG_FREERTOS_UNICORE问题

温故知新--常温常新
![统计无向图中无法互相到达点对数[经典建邻接表+DFS统计 -> 并查集优化][并查集手册/写的详细]](/img/cc/a0be58eddc72c22a9a6ee5c61eb81a.png)
统计无向图中无法互相到达点对数[经典建邻接表+DFS统计 -> 并查集优化][并查集手册/写的详细]

Other service registration and discovery

Technical dry goods | what is a big model? Oversized model? Foundation Model?

Special topic II on mathematical physics of the sprint strong foundation program

當Transformer遇見偏微分方程求解

技术干货|什么是大模型?超大模型?Foundation Model?
![自定义JSP[if,foreach,数据,select]标签](/img/a2/fc75c182d572d86f4466323e31d6c3.png)
自定义JSP[if,foreach,数据,select]标签
随机推荐
What are the skills and methods for slip ring installation
根据文件名批量生成文件夹
Hit the point! The largest model training collection!
深度学习方法求解平均场博弈论问题
墨者学院-SQL注入漏洞测试(报错盲注)
数据库面试题+sql语句解析
These 10 copywriting artifacts help you speed up the code. Are you still worried that you can't write a copywriting for US media?
Lorsque le transformateur rencontre l'équation différentielle partielle
com. fasterxml. jackson. databind. exc.MismatchedInputException: Expected array or string. at [Source:x
Deep learning method for solving mean field game theory problems
简单快速的数网络(网络中的网络套娃)
How to open an account on the mobile phone? Is it safe to open an account online and speculate in stocks
其他服务注册与发现
高清滑环生产过程当中的质量如何把控
Interface test framework practice (I) | requests and interface request construction
matlab数据类型 —— 字符型
如何写好测试用例以及go单元测试工具testify简单介绍
From bitmap to bloom filter, C # implementation
CH423要如何使用,便宜的国产IO扩展芯片
Employment prospect of GIS and remote sensing specialty and ranking selection of universities in 2022