当前位置:网站首页>3线spi屏幕驱动方式
3线spi屏幕驱动方式
2022-06-27 00:13: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;
红色放到第一个字节,绿色放到第二个字节,蓝色放到低三个字节,且都是高位对齐。低位空置。转换后屏幕即可正常显示。
边栏推荐
- Oracle 数据库基本知识概念
- Leetcode skimming 4 Find the median of two positive arrays
- 如何把老式键盘转换成USB键盘并且自己编程?
- Great health industry annual must attend event, 2022 Shandong International Great Health Industry Expo
- 一键加速索尼相机SD卡文件的复制操作,文件操作批处理教程
- redis详细教程
- Reading graph augmentations to learn graph representations (lg2ar)
- How to control the quality of HD slip ring in the production process
- Timing mechanism of LwIP
- CEC-I 中华学习机使用说明与问答
猜你喜欢

温故知新--常温常新

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

万字详解-MindArmour 小白教程!

全網最全的混合精度訓練原理

技术干货|什么是大模型?超大模型?Foundation Model?

Employment prospect of GIS and remote sensing specialty and ranking selection of universities in 2022

Lorsque le transformateur rencontre l'équation différentielle partielle

What are the skills and methods for slip ring installation

目标追踪拍摄?目标遮挡拍摄?拥有19亿安装量的花瓣app,究竟有什么别出心裁的功能如此吸引用户?

Memorizing byte order of big and small end
随机推荐
How to open an account on the mobile phone? Is it safe to open an account online and speculate in stocks
Super hard core! Can the family photo album on Huawei's smart screen be classified automatically and accurately?
Other service registration and discovery
2022 Health Expo, Shandong health care exhibition, postpartum health and sleep health exhibition
技术干货|什么是大模型?超大模型?Foundation Model?
find_circ详细使用指南
敲重点!最全大模型训练合集!
Oracle 數據庫基本知識概念
2022年地理信息系统与遥感专业就业前景与升学高校排名选择
Overview of Freescale MCU
冲刺强基计划数学物理专题二
中信证券佣金 网上开户炒股安全吗
接口测试框架实战(一) | Requests 与接口请求构造
kubeadm创建kubernetes集群
Technical dry goods | what is a big model? Oversized model? Foundation Model?
简单快速的数网络(网络中的网络套娃)
Lwip之ARP模块实现
一键加速索尼相机SD卡文件的复制操作,文件操作批处理教程
CEC-I 中华学习机使用说明与问答
How to use Pinia (I) introduce Pinia into the project