当前位置:网站首页>3-wire SPI screen driving mode
3-wire SPI screen driving mode
2022-06-27 00:50:00 【NULL_ one thousand nine hundred and sixty-nine】
Preface
Recently, I studied 3 Line spi The driving mode of the screen . The driving chip of the screen is ILI9488, Compared with 4 Line ,3 Line spi The screen does not use DC Write orders / Write data control line .DC=0 To write an order ,DC=1 Write data .
3 Line spi data format

3 Line spi Will be DC The command is placed on every 8 The highest bit of bit data . It's still boring to say so , Take a look at specific examples .
If spi send out 0x55, Generally used MSB, The way that the high position comes first .
that SDA(MOSI) The data line is like this :
01010101
If you want to suppose dc command , be 0x55 To be sent in two bytes , hypothesis DC=1, be SDA(MOSI) The data are as follows :
10101010 1
Low byte High byte
Equivalent to 0x55 Convert to :0x80AA. At the same time, it should be set in the single chip microcomputer spi The data is 9 position . After many explorations , The conversion formula is :
uint16_t data = (0x8000&(cmd<<15))|(0x7f&(cmd>>1)) ;
Specific in esp32 In, you need to change the sending function to the following :
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.
}
Only in this way can we communicate with the screen normally . This causes the communication speed to decrease , Difficult to adopt dma Transfer a lot of data . The reason is that each byte must be disassembled and put together 2 Bytes and then send . It's so inconvenient , It took a lot of time to adjust this .
Personally feel 3 Line spi Communication methods and their bullshit , Extremely inefficient , It's still honest and practical 4 Line spi Or SCM 8080 Interface to drive the screen . Some screens DC Pin use RS To represent the , The author did not understand at the beginning , Did you find this screen DC Pin , To study 3 Line spi, Later, I found that the screen refresh rate was too low , Refreshing a full screen requires 10s The clock . Finally found RS=DC, Immediately change to 4 Line spi, Cool, dropping .
however ILI9488 The most important thing about this driver chip is that it uses spi The way , Only support 8bit and 18bit The color format of , I won't support it 16bit. This is the result of the experiment , The specification states that 4 Line spi when , Can support 16bit Color ,
But will 0x3A write in 0x05(16bit) The screen is not displayed , Only will 0x3A write in 0x06(18bit) when , To show the color . This is very stupid .
ILI9488 18 Bit color format

Usually used 16 Bit color , So we're using 18 Bit color needs to be replaced . And then through spi send out . The specific conversion method is
colors[0] = (color>>8)&0xf8;
colors[1] = (color>>3)&0xfc;
colors[2] = (color<<3)&0xfc;
Put red in the first byte , Green in the second byte , Put blue three bytes lower , And they are all high aligned . Low vacancy . After conversion, the screen can be displayed normally .
边栏推荐
猜你喜欢

新型冠状病毒变异Delta毒株的模拟(MindSPONGE应用)

【UVM实战 ===> Episode_3 】~ Assertion、Sequence、Property

根据文件名批量生成文件夹

How to use Pinia (I) introduce Pinia into the project

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

Skills needing attention in selection and purchase of slip ring

What are the skills and methods for slip ring installation
![寻找旋转排序数组中的最小值 II[经典抽象二分 + 如何破局左中右三者相等]](/img/75/05d5765588dfde971167fbc72e2aa8.png)
寻找旋转排序数组中的最小值 II[经典抽象二分 + 如何破局左中右三者相等]

When transformer encounters partial differential equation solution

Mindspire, a domestic framework, cooperates with Shanshui nature conservation center to find and protect the treasure life in the "China water tower"
随机推荐
At present, which securities company is the best and safest to open an account for stock speculation?
The [MySQL] time field is set to the current time by default
如何把老式键盘转换成USB键盘并且自己编程?
當Transformer遇見偏微分方程求解
光谱共焦如何测量玻璃基板厚度
Concepts de base de données Oracle
BootstrapBlazor + FreeSql实战 Chart 图表使用(2)
MySQL之账号管理、建库以及四大引擎+案例
基于SSMP的宠物医院管理系统
小白看MySQL--windows环境安装MySQL
墨者学院-X-Forwarded-For注入漏洞实战
kubeadm创建kubernetes集群
Batch generate folders based on file names
指南针开户安全的吗?
Central Limit Theorem
直播回顾 | 子芽&CCF TF:云原生场景下软件供应链风险治理技术浅谈
From bitmap to bloom filter, C # implementation
Encapsulate servlet unified processing request
Super hard core! Can the family photo album on Huawei's smart screen be classified automatically and accurately?
Lorsque le transformateur rencontre l'équation différentielle partielle