STM32-FSMC-LCD Detailed Explanation

Publisher:tnzph488Latest update time:2016-10-17 Source: eefocusKeywords:STM32  FSMC  LCD Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
LCD has the following control lines:

CS: Chip Select chip select, low level valid
RS: Register Select register select
WR: Write write signal, low level valid
RD: Read read signal, low level valid
RESET: Reset signal, low level valid
DB0-DB15: Data line

Suppose all these lines are controlled by ordinary IO ports. According to the LCD control chip manual (most control chips have similar timing):
If the situation is as follows:
All IOs of DB0-DB15 are 1 (indicating data 0xff), or any other value, here we take 0xff as an example.
CS is 0 (indicating that the chip is selected, and the chip will be effective for the incoming data when CS is pulled low)
RS is 1 (indicating that the value transmitted on DB0-15 is to be written to the register), if it is 0, it means that the data is transmitted.
WR is 0, RD is 1 (indicating a write action), and vice versa is a read action.
RESET is always high, if RESET is low, it will cause the chip to restart.
In this case, a value of 0xff will be transmitted to the chip, and the LCD control chip will interpret it as a write register value. After the LCD control chip receives the value on DB0-15, according to the situation of other control lines, it concludes that this 0xff is used to set the register. In general, the LCD control chip will treat the upper 8 bits of the incoming register value as the register address (because there must be more than one register inside the chip), and the lower 8 bits as the actual value to be assigned to the corresponding register. In this way, the timing of writing the internal register of the LCD control chip is completed.

If the above situation remains unchanged and only RS is set low, the situation is as follows: the LCD control chip will treat the data on DB0-15 as a simple data value. If the LCD is in the drawing state, the value 0xff passed in will be displayed on the corresponding point, and 0xffff means white, so the corresponding point is white. Before this data value is passed, the program will definitely tell the LCD control chip where the point to be written is by setting the register value.

If the above two situations remain unchanged, the WR and RD signals are reversed (WR=1, RD=0), then the write signal will be converted into a read signal. Under the read signal, the main control chip needs to read the value of DB0-15, and the LCD control chip will set the value of DB0-15 to complete the timing of reading data.

The timing of reading registers is a little more complicated. The first step is to set both WR and RD low, and the main control chip transmits the register address through DB0-15. The second step is the same as reading data before, set WR high, RD low, and read the value of DB0-15. During this whole process, RS is always low.

Well, the above is the method of directly controlling LCD with IO. If it is put into STM32, direct control with IO is very inefficient. STM32 has FSMC (in fact, other chips basically have similar bus functions). The advantage of FSMC is that once you set it up, the control lines and data lines such as WR, RD, DB0-DB15 are all automatically controlled by FSMC. For example, when you write in the program:
*(volatile unsigned short int *)(0x60000000)=val;
then FSMC will automatically perform a write operation, and the corresponding WE and RD pins of the main control chip will show the write timing (that is, WE=0, RD=1), and the value of data val will also be automatically presented through DB0-15 (that is, FSMC-D0:FSMC-D15=val). The address 0x60000000 will be presented on the data line (that is, A0-A25=0, the correspondence of the address line is the most troublesome, it depends on the specific situation, and you should read the FSMC manual carefully).
Then in terms of hardware, what we need to do is just the connection between MCU and LCD control chip:
WE-WR, both are valid at low level
RD-RD, both are valid at low level
FSMC-D0-15 connected to LCD DB0-15
After the connection is completed, the read and write timing will be automatically completed by FSMC. But there is still a very critical problem, that is, RS is not connected, CS is not connected. Because in FSMC, there is no corresponding RS and CS pins. What should I do? At this time, there is a good way, which is to use a certain address line to connect RS. For example, if we choose A16 as the address line to connect, then when we want to write to the register, we need RS, that is, A16 to be set high. How to do it in software? That is to change the address that FSMC wants to write to 0x60020000, as follows:
*(volatile unsigned short int *)(0x60020000)=val;
At this time, A16 will be pulled high while executing other FSMC, because A0-A18 will present the address 0x60020000. Bit17=1 in 0x60020000 will cause A16 to be 1.
When reading data, the address is changed from 0x60020000 to 0x60000000, and A16 is 0 at this time.

Then some friends will have questions. First, why is the address 0x6xxxxxxx instead of 0x0xxxxxxx? Second, how to connect CS? Third, why does Bit17 correspond to A16?
Let's look at the first two questions first. Everyone finds the FSMC manual of STM32. In the FSMC manual, we can easily find that FSMC uses the address of 0x60000000-0x6fffffff as NOR/PRAM (a total of 256M address range). And this storage block is divided into four parts, each with a 64M address range. When reading and writing one of the storage blocks, the corresponding NEx will be set low. Here, we solve our two problems. First, the operation timing of LCD is the same as NOR/PRAM (why is it the same? Find the timing of NOR/PRAM yourself), so we choose the address range of 0x6xxxxxxx (select this address range, when operating this address, FSMC will show the timing of NOR/PRAM). Second, we can connect NEx to the CS of the LCD, as long as the address we operate on is within the first memory block (i.e. the address range 0-0x3ffffff).

For the third question, let's look at the description of memory word width in the FSMC manual. We found that when the external memory is 16 bits, the hardware pins A0-A24 represent the values ​​of address lines A1-A25, so we need to shift the value of Bit17, which will actually be reflected in the IO A16. Regarding the data width and shift, beginners may be confused. When you come into contact with devices such as NOR/PRAM, you will find that the buses of many chips are designed in this way to save address lines.

The above completely solves the problem of how to connect the LCD driver to the FSMC. If the reader does not understand, it is recommended to copy the above text and the chapter corresponding to NOR/PRAM in the FSMC manual. If you still don't understand, continue to copy it until you understand.
Although the above only explains FSMC for LCD, the operation of NOR and external RAM is similar, except that there are more address lines for addressing.

Keywords:STM32  FSMC  LCD Reference address:STM32-FSMC-LCD Detailed Explanation

Previous article:STM32 SST25VF016B Driver
Next article:STM32 serial port experiment printf output problem

Recommended ReadingLatest update time:2024-11-17 01:59

A Practical Hardware Design of Segment Code LCD Driver Circuit
1. Overview There are two commonly used displays in instruments and meters, one is light-emitting diode (LED) and the other is liquid crystal display (LCD). These two displays are low-cost, flexible in configuration, and easy to interface with single-chip microcomputers. The latter has small driving current, low
[Power Management]
A Practical Hardware Design of Segment Code LCD Driver Circuit
Detailed explanation of the difficulties of STM32 interface FSMC/FMC
          The STM32F767's FMC divides the external memory into six fixed-size 256M storage areas, as shown below:         The FMC memory block 1 (Bank1) of STM32F767 is divided into 4 areas, each area manages 64M bytes of space, and each area has independent registers to configure the connected storage. The 256M
[Microcontroller]
Detailed explanation of the difficulties of STM32 interface FSMC/FMC
LCD1602 screen driver (custom characters)
1. Timing diagram 2. Code 3. Custom characters                                                             Timing diagram Code: #include reg51.h #include intrins.h sbit RS = P2^4; //define port sbit RW = P2^5; sbit EN = P2^6; void Delayus(unsigned char t) // us level delay {    while(--t); } void Delay
[Microcontroller]
LCD1602 screen driver (custom characters)
[STM32 Cotex-M3 processor series programming] External key interrupt
#include "stm32f10x.h" unsigned int TimingDelay;   void Delay(unsigned int x) {   TimingDelay=x; while(TimingDelay--); }     void EXTI9_5_IRQHandler(void) //interrupt handling function {    unsigned int tt;    tt=6553500;    if (EXTI_GetITStatus(EXTI_Line5)!=RESET)    { GPIO_SetBits(GPI
[Microcontroller]
How to use PIC microcontroller to debug LCD controller
There are two issues with using a PIC to debug an LCD application. First, the LCD controller will stop when the device is halted. Second, the ICD pins are segment-shared on the PIC16F946/917/916/914/913 MCUs. When debugging, the device will halt at breakpoints and when the user presses the halt button. If the ICD is
[Microcontroller]
How to use PIC microcontroller to debug LCD controller
STM32 read protection function and clear read protection function settings [transfer]
1. STM32 protection measures for internal Flash      All STM32 chips provide Flash protection to prevent illegal access to the Flash - write protection and read protection.     1) Read protection is commonly referred to as "encryption", which acts on the entire Flash storage area. Once Flash read protection is set, th
[Microcontroller]
STM32 peripheral driver---SysTick precise delay
Microcontroller: STM32F103  Library functions: V3.5  Description: Use the SysTick in the system kernel file core_cm3.c to achieve 1ms, 1us accurate delay, clock 72MHz, involving the registration of the interrupt service SysTick_Handler. delay.h #ifndef     __DELAY_H__ #define     __DELAY_H__ #include "stm32f10
[Microcontroller]
Configuration instructions for ports after 5 in STM32EXTI external interrupt
When we use external interrupts, basically every io port of STM32 can be used as an external interrupt. When setting the interrupt priority, there is a very vague place that is easy to make mistakes. Let me talk about it here.   I skipped the code for defining the interrupt port. Here, I assume that the PG8 port is u
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号