当前位置:网站首页>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;
紅色放到第一個字節,綠色放到第二個字節,藍色放到低三個字節,且都是高比特對齊。低比特空置。轉換後屏幕即可正常顯示。
边栏推荐
- 大健康行业年度必参盛会,2022山东国际大健康产业博览会
- 复杂数据没头绪?
- Great health industry annual must attend event, 2022 Shandong International Great Health Industry Expo
- Flink 实战问题(七):No Watermark(Watermarks are only available EventTime is used)
- 1+1<2 ?! HESIC论文解读
- 运用物理信息神经网络求解流体力学方程
- 用代码生成流程图,Markdown的使用方法
- Oracle database basics concepts
- 中信证券佣金 网上开户炒股安全吗
- find_circ详细使用指南
猜你喜欢

冲刺强基计划数学物理专题二

墨者学院-X-Forwarded-For注入漏洞实战

Competition Registration | one of the key ai+ scientific computing competitions - China open source scientific software creativity competition, competing for 100000 bonus!

复杂数据没头绪?

敲重点!最全大模型训练合集!

一键加速索尼相机SD卡文件的复制操作,文件操作批处理教程

Simple and fast digital network (network dolls in the network)

CH423要如何使用,便宜的国产IO扩展芯片

In depth understanding of UDP in the transport layer and the use of UDP in sockets

Super hard core! Can the family photo album on Huawei's smart screen be classified automatically and accurately?
随机推荐
05 | standard design (Part 2): how to standardize the different styles of commit information, which are difficult to read?
全網最全的混合精度訓練原理
當Transformer遇見偏微分方程求解
统一结果集的封装
墨者学院-X-Forwarded-For注入漏洞实战
Deep learning method for solving mean field game theory problems
【Mysql】时间字段默认设置为当前时间
MindSpore新型轻量级神经网络GhostNet,在ImageNet分类、图像识别和目标检测等多个应用场景效果优异!
Leetcode skimming 4 Find the median of two positive arrays
05 | 規範設計(下):commit 信息風格迥异、難以閱讀,如何規範?
In the Internet industry, there are many certificates with high gold content. How many do you have?
test
当Transformer遇见偏微分方程求解
自定义JSP[if,foreach,数据,select]标签
数据库面试题+sql语句解析
数字格式化的 js 库
In depth understanding of UDP in the transport layer and the use of UDP in sockets
Competition Registration | one of the key ai+ scientific computing competitions - China open source scientific software creativity competition, competing for 100000 bonus!
Le principe le plus complet de formation à la précision hybride pour l'ensemble du réseau
Flink 实战问题(七):No Watermark(Watermarks are only available EventTime is used)