当前位置:网站首页>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

 Insert picture description here
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

 Insert picture description here
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 .

原网站

版权声明
本文为[NULL_ one thousand nine hundred and sixty-nine]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/178/202206270012533825.html