Friends who have used the STM32F10XX series know that there are generally two ways to drive the LCD; one is to use the IO port to simulate the operation of the LCD, and the other is to use the FSMC interface of the STM32F10XX to operate the LCD; of course, the latter is definitely faster than the former, because FSMC is a peripheral of STM32, you just need to throw the data to it and it will complete the driving for you. As long as the FSMC interface is set up, the C language code for transmitting data can be simplified to one sentence, and the CPU utilization is greatly increased.
Reference address:STM32F10XX series uses FSMC interface to drive LCD
I have used STM32F103RBT to make an MP3 with display before. At that time, I used IO to simulate the LCD. It was a bit troublesome to control because many macro definitions were needed to package some IO port operations. Just writing a piece of data required several instructions. Reading and writing also required changing the input and output direction of the IO port. Therefore, using IO port to simulate the LCD was much slower than the FSMC interface driver. From the execution point of view, FSMC is parallel with other codes, while IO port simulation is serial with other codes. Which one do you think is faster? Well, without further ado, I will show you the FSMC interface I set up.
/**********************************************
* Function name: LCD_GPIO_Config
* Description: Configure LCD I/O according to FSMC
* Input : None
* Output: None
* Example: None
* Note: None
*********************************************/
void LCD_GPIO_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable FSMC clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
/* Enable FSMC corresponding to the corresponding pin clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE, ENABLE);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
/* Configure LCD backlight control pins */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* Configure LCD reset control pin */
/* LCD reset is together with system reset, so no other pins are used for reset */ (I did not use other IO to reset it. The PE1 below is not used. I connected it to the LED)
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/* Configure the data lines corresponding to FSMC, FSMC-D0~D15: PD 14 15 0 1, PE 7 8 9 10 11 12 13 14 15, PD 8 9 10*/
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 |
GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 |
GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 |
GPIO_Pin_15;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/* Configure the corresponding control lines of FSMC
* PD4-FSMC_NOE :LCD-RD Read
* PD5-FSMC_NWE: LCD-WR write
* PD7-FSMC_NE1: LCD-CS chip select
* PD11-FSMC_A16 :LCD-RS/DC command/data
**********************************************/
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_7|GPIO_Pin_11;
GPIO_Init(GPIOD, &GPIO_InitStructure);
}
/**********************************************
* Function name: LCD_FSMC_Config
* Description: LCD FSMC mode configuration
* Input : None
* Output: None
* Example: None
* Note: None
*********************************************/
void LCD_FSMC_Config(void)
{
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef p;
p.FSMC_AddressSetupTime = 0x02; //Address establishment time
p.FSMC_AddressHoldTime = 0x00; //Address hold time
p.FSMC_DataSetupTime = 0x05; //Data establishment time
p.FSMC_BusTurnAroundDuration = 0x00;
p.FSMC_CLKDivision = 0x00;
p.FSMC_DataLatency = 0x00;
p.FSMC_AccessMode = FSMC_AccessMode_B;
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_NOR;
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_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;
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
/* Enable FSMC Bank1_SRAM Bank */
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
}
FSMC can work with this setting (of course it can also be changed to other working modes). I use A16 as the data and command selection line. Add the following two sentences
#define LCD_REG (*(__IO u16 *)((uint32_t)0x60000000))
#define LCD_RAM (*(__IO u16 *)((uint32_t)0x60020000)) We can then read and write the LCD as two addresses, which is very convenient.
I'll stop here. If you have other opinions, please feel free to raise them.
Previous article:STM32F10XX Application Notes - GPIO Settings
Next article:STM32 directly drives ov7670 development notes
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
MoreDaily News
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
Guess you like
- Over View can customize the format and content of the audio body according to your needs
- What should I do if my WIFI is stolen?
- Architecture Issues
- What do these three graphs (parameters) of the op amp mean?
- [RVB2601 Creative Application Development] Network Weather Clock
- The process of responding to interrupts in DSP
- [RVB2601 Creative Application Development] 1. Development Environment Construction
- EEWORLD University ---- Live Replay: Microchip Security Series 6 - Trust Your Firmware: Secure Boot Application Processors
- [Home Smart Lighting Control and Indoor Environment Monitoring System]--8. Merge 2 projects in ON-SEMI development software
- 51 MCU sends data to the serial port