Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use STM32 driver LCD

2025-02-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to use the STM32 driver LCD for you. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

01 driving timing

What we usually call the MCU-LCD interface is the 8080 interface. For a detailed description of the 8080 interface, see "the principle of STM32 driving LCD".

The following is the 8080 mode bus timing given by LMT028DN

Here are the parameters in the bus timing

Time series parameter

Tast- > address setting time

Taht- > address hold time (write)

Tchw- > Chip Select High Pulse width

Tcs- > Chip selection setting time (write)

Tcsf- > chip select wait time (write)

Twc- > write cycle

Twrh- > Control Pulse High level time

Twrl- > Control Pulse low level time

Tdst- > data setting time

Tdht- > data retention time

According to the configuration and timing diagram of FSMC, the three timing parameters we need are

Three important parameters

1. Address establishment time: 5ns

2. Address retention time: 13ns

3. Data creation time: 13ns

The above data are the minimum time to meet the timing diagram, in practical application, can not be set to the minimum value, nor can it be greater than the maximum value (if any), mainly based on practical application, if the setting time is too fast, but unstable.

Because we use interface 8080 to drive LCD to drive SRAM, we can choose mode 1 and mode An of FSMC, but the switch of / RD, that is, the switch of NOE of FSMC, can only choose mode A, observe the sequence diagram, and read and write in the same order, so we can choose a configuration that is consistent in read and write.

02 FSMC peripheral configuration

FSMC peripherals configuration code. For more information on FSMC peripherals, please see "introduction to FSMC peripherals of STM32".

ReadWriteTiming.FSMC_AddressSetupTime = 0x02; / / address set-up time (ADDSET) is 2 HCLK 2*1/120M=16nsreadWriteTiming.FSMC_AddressHoldTime = 0x02; / / address hold time (ADDHLD), 16nsreadWriteTiming.FSMC _ DataSetupTime = 0x06; / / data setup time, 50nsreadWriteTiming.FSMC_BusTurnAroundDuration = 0x00swap / bus recovery time readWriteTiming.FSMC_CLKDivision = 0x00WTA / clock frequency division factor readWriteTiming.FSMC_DataLatency = 0x00 / / data generation time readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_A; / / Mode A FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;// here we use NE1, which corresponds to BTCR [6], [7]. FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;// unreused data address FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;// FSMC_MemoryType_SRAM; FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b;// memory data width is 8bit FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;// FSMC_BurstAccessMode_Disable; FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;// memory write enable FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;// read and write use the same timing FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = & readWriteTiming / / read / write timing FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = & readWriteTiming;// write timing

Read and write interface code:

Structure definition, which takes advantage of the structure address increment feature

Typedef struct {uint8_t LCD_CMD;// for LCD command operation uint8_t LCD_DATA;// for LCD data operation} LCD_TypeDef;#define LCD_BASE ((uint32_t) (0x60000000 | 0x0000FFFF)) # define LCD ((LCD_TypeDef *) LCD_BAS

Read-write interface

Void LMT028_Write_Cmd (uint8_t usCmd) {LCD- > LCD_CMD=usCmd;} void LMT028_Write_Data (uint8_t usData) {LCD- > LCD_DATA = usData;}

It can also be written simply and clearly as follows

# define FSMC_Addr_LMT028_CMD ((uint32_t) 0x60000000) # define FSMC_Addr_LMT028_DATA ((uint32_t) 0x60010000) void LMT028_Write_Cmd (uint8_t usCmd) {* ((uint32_t *) FSMC_Addr_LMT028_CMD) = usCmd;} void LMT028_Write_Data (uint8_t usData) {* ((uint32_t *) FSMC_Addr_LMT028_DATA) = usData;} 03 backlight driver

LED backlight driver, according to the high-level duty cycle, a total of 32 brightness levels, the use of PWM driver is the most appropriate, by adjusting the duty cycle, adjust the brightness.

04 reset driver

The reset pin is greater than the low level of the 10ms, and then the high level of the maximum 170ms

This is the end of this article on "how to use STM32 driver LCD". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report