3608 views|5 replies

73

Posts

0

Resources
The OP
 

[N32L43X Review] 5. SPI driver LCD 1.3 ST7789 [Copy link]

 

I have been busy with work recently, which has delayed the progress of the evaluation.

When I applied for the board, I mainly wanted to test the SPI performance of N32. The M4 core with a main frequency of 108MHz was very attractive to me.

It is perfect for refreshing LCD

Unfortunately, the SPI module uses the APB2 bus, which is only half of the main frequency, and the SPI module needs to divide the APB2 bus by at least half.

That is 1/4 of the main frequency, so the fastest speed is only 27MHz. And I also need to use a USB module, the main frequency is 96MHz, that is, the highest frequency of SPI is only 24MHz, what a pity.

The most convenient solution for SPI screen flashing is ESP32. Its SPI can reach 80MHz, and it can flash a 240x240 screen very smoothly.

The following is the driver, you can directly download the attachment for details

void SPIConfig(void){
    SPI_InitType SPI_InitStructure;

    GPIO_InitType GPIO_InitStructure;
	
	RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_SPI1, ENABLE);


    GPIO_InitStructure.Pin = SPI_LCD_SCK_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
    GPIO_InitStructure.GPIO_Alternate = GPIO_AF1_SPI1;
    GPIO_InitStructure.GPIO_Current = GPIO_DC_4mA;
    GPIO_InitStructure.GPIO_Pull = GPIO_No_Pull;
    GPIO_InitPeripheral(SPI_LCD_SCK_PORT, &GPIO_InitStructure);

    GPIO_InitStructure.Pin = SPI_LCD_MOSI_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
    GPIO_InitStructure.GPIO_Alternate = GPIO_AF0_SPI1;
    GPIO_InitStructure.GPIO_Current = GPIO_DC_4mA;
    GPIO_InitStructure.GPIO_Pull = GPIO_No_Pull;
    GPIO_InitPeripheral(SPI_LCD_MOSI_PORT, &GPIO_InitStructure);

    SPI_InitStructure.DataDirection = SPI_DIR_SINGLELINE_TX;
    SPI_InitStructure.SpiMode = SPI_MODE_MASTER;
    SPI_InitStructure.DataLen = SPI_DATA_SIZE_8BITS;
#if 0
    SPI_InitStructure.CLKPOL = SPI_CLKPOL_LOW;
    SPI_InitStructure.CLKPHA = SPI_CLKPHA_FIRST_EDGE;
	SPI_InitStructure.CLKPHA = SPI_CLKPHA_SECOND_EDGE;
#else
    SPI_InitStructure.CLKPOL = SPI_CLKPOL_HIGH;
    SPI_InitStructure.CLKPHA = SPI_CLKPHA_SECOND_EDGE;
#endif
    SPI_InitStructure.NSS = SPI_NSS_SOFT;
    SPI_InitStructure.BaudRatePres = SPI_BR_PRESCALER_2; // 48/4 = 12MHz
    SPI_InitStructure.FirstBit = SPI_FB_MSB;
    SPI_InitStructure.CRCPoly = 7;

    SPI_Init(SPI_LCD, &SPI_InitStructure);
    SPI_Enable(SPI_LCD, ENABLE);	
}
#if LCDTYPE == 0
void LCD_Writ_Bus(uint8_t dat) {
    // uint8_t shiftdat = 0;
    // shiftdat = shift_byte(dat);
    LCD_CS_CLR;
    // LCD_WR_SET;
    DATAOUT(dat);
    LCD_WR_CLR;
    // delay_us(5);
    LCD_WR_SET;
    LCD_CS_SET;
    LCD_DC_SET;
}
#elif LCDTYPE == 1
void LCD_Writ_Bus(uint8_t dat) {
    uint16_t retry = 0;
    /* Wait for SPIy Tx buffer empty */
    while (SPI_I2S_GetStatus(SPI_LCD, SPI_I2S_TE_FLAG) == RESET)
        ;
    /* Send SPIz data */
    SPI_I2S_TransmitData(SPI_LCD, dat);
}

#endif

Here you can use the previous Shell function. After powering on, the screen will refresh with a gradient color. After typing setLcd 0, you can stop the scheduled refresh task.

Type setLcd 1 to start the task.

You can also type clearLcd x to refresh the desired colors. We have already talked about how to use them before.

For people who often write interfaces, the Shell function is much more convenient. You can adjust the font size, color, and position without having to compile, burn, adjust, compile, and burn again and again.

Although there are many GUIs now, all of them have designers, but they still take up too much memory, and for low-resolution screens it feels like an overkill.

I recently found uGUI. This project is very small and has a good architecture. There are only two files in total. If you are interested, let's try it in the next issue.

By the way, there is another good thing in the routine to share with you. Vscode should be familiar to everyone. EIDE is a plug-in of Vscode, which can import MDK projects. It is very comfortable to write programs with Vscode.

EIDE is also powerful. You can write compilers directly without MDK. The main thing is that the compiler can use MDK, which can avoid a lot of unnecessary trouble. If there is a chance, this part will be taken out for a separate evaluation.

5.SPI驱动LCD ST7789.rar

20.52 MB, downloads: 18

This post is from Domestic Chip Exchange

Latest reply

Okay, looking forward to it. . .   Details Published on 2022-7-18 20:50
 
 

6818

Posts

11

Resources
2
 
How is the font library? Can I learn from it? Hehe!
This post is from Domestic Chip Exchange

Comments

You can use two arrays to create a custom font library. Basically, a hundred or so fonts are enough for a project.  Details Published on 2022-7-18 09:01
You can use two arrays to create a custom font library. Basically, a hundred or so fonts are enough for a project.  Details Published on 2022-7-17 23:46
 
 
 

5998

Posts

6

Resources
3
 
lugl4313820 posted on 2022-7-17 21:03 How is the font library? Can I learn from it? Hehe!

You can use two arrays to create a custom font library. Basically, a hundred or so fonts are enough for a project.

This post is from Domestic Chip Exchange
 
 
 

5998

Posts

6

Resources
4
 

If you want to refresh quickly, you still need a parallel port

This post is from Domestic Chip Exchange
 
 
 

205

Posts

0

Resources
5
 
lugl4313820 posted on 2022-7-17 21:03 How is the font library? Can I learn from it? Hehe!

Look at mine, look at mine, sharing the GBK Chinese full font library, mixed display of Chinese and English

This post is from Domestic Chip Exchange

Comments

Okay, looking forward to it. . .  Details Published on 2022-7-18 20:50
Personal signatureWe are a team and we work as a team !
 
 
 

6818

Posts

11

Resources
6
 
xld0932 posted on 2022-7-18 09:01 Look at mine, look at mine, share the GBK Chinese full font library, Chinese and English mixed display

Okay, looking forward to it. . .

This post is from Domestic Chip Exchange
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
Homemade STEVAL-IPM05F 3Sh board: FOC motor control 400V/8A non-sensing/sensing Hall/sensing encoder and other reference programs...

This post was last edited by music_586 on 2019-4-4 19:06 This content was originally created by EEWORLD forum user musi ...

C language uses binary tree to parse polynomials and evaluate

It mainly realizes the analysis of polynomial data calculation. If there is a need to make a simple calculator based on ...

Zhouyi Compass Simulation Experiment 2——Environment and Routine Analysis

Zhouyi Compass Simulation Experiment 2——Environment and Routine Analysis In simulation experiment 1 (https://bbs.eewor ...

【Development and application based on NUCLEO-F746ZG motor】13. Parameter configuration - USART3 configuration

The function of this serial port on the development board is to communicate with ST-LINK, and then connect ST_LINK2 to t ...

[EEWorld invites you to play disassembly] PISEN fast charging power bank 10500mAh 22.5W

Quote: Thank you EEWorld for inviting you to the disassembly (fourth issue): popular power bank disassembly event. As w ...

Please tell me why this machine often burns the starting resistor at the customer's place

Please tell me why the resistor burned out and how to fix it? 627875627874627873

[Flower carving hands-on] Interesting and fun music visualization series of small projects (26) - LED hypercube

This post was last edited by eagler8 on 2022-10-5 08:59 I had the urge to do a series of topics on sound visualization. ...

Is it possible to perform socket communication without IP and port number?

When using socket communication, whether it is internal communication within the local machine or communication betwee ...

Development Background and Advantages of SiC Power Devices

SiC power components have higher withstand voltage, lower on-resistance, can operate at higher speeds, and can operate a ...

【Digi-Key Follow me Issue 2】Task Collection

I got the board quite late, and after completing the task, I got busy with a lot of other things so I didn't have time t ...

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list