uC/GUI is a graphical user interface (GUI) software package for embedded systems launched by MICrigm. Since uC/GUI is completely written in ANSI-C, it has nothing to do with the processor and can be easily ported to different operating systems and embedded microprocessors, and can support graphic LCDs of different sizes. It adopts a hierarchical design, is powerful, and is easy to port. It is widely used in embedded fields such as PDAs, set-top boxes, and DVD NCD players. This article introduces the porting of uC/GUI on the ARM core S3C44B0X in detail. Practice has proved that uC/GUI has good real-time performance and stability as well as broad application prospects.
1. Hardware connection and LCD display principle
The hardware used in this design adopts ARM7 development board, and the LCD module is L78C64, which is a 7.8in 256-color STN LCD display with a resolution of 640×480.
The definition of the LCD controller external interface signal and its corresponding relationship with the LCD module signals are as follows:
(1) VFRAME: The frame synchronization signal between the LCD controller and the LCD driver. This signal is responsible for indicating the start time of a new frame of the LCD screen. The LCD controller inserts a VFRAME signal immediately after a complete frame display is completed and starts the display of a new frame. This signal corresponds to the YD signal of the LCD module;
(2) VLINE: Line synchronization pulse signal between LCD controller and LCD driver. This signal is used to transfer the contents of LCD driver horizontal line (row) shift register to LCD screen display. LCD controller inserts a VLINE signal after the entire horizontal line (entire row) data is shifted into LCD controller. This signal corresponds to the LP signal of LCD module;
(3) VCLK: The pixel clock signal between the LCD controller and the LCD driver. The data sent by the LCD controller is sent at the rising edge of VCLK and is sampled by the LCD driver at the falling edge of VCLK. This signal corresponds to the XCK signal of the LCD module;
(4) VM: AC signal of LCD driver. VM signal is used by LCD driver to change the voltage polarity of rows and columns, thereby controlling the display and extinguishing of pixels. VM signal can be synchronized with each frame or with a variable number of VLINE signals;
(5) VD3~0 LCD: pixel data input port. Corresponding to D3~0 of LCD module:
(6) VD7~4 LCD: Pixel data input port. Corresponding to D7~4 of LCD module.
Liquid crystal display principle: The data that fills the entire screen is called a "frame" of data. YD is the frame synchronization signal, which starts a new frame of data on the LCD screen. The time length between two YD pulses is called the frame period. According to the characteristics of the LCD module, the refresh time is 12 to 14ms and the frequency is 70 to 80Hz. Each frame includes 480 LP pulses. LP is the row (480 rows) data input latch signal, that is, the row synchronization pulse signal. This signal starts a new row of data on the LCD screen. XCK is the row data input signal, that is, the clock signal for pixel data transmission in each row. Each group of 8-bit data is input and latched at the falling edge of XCK, so each row includes 640×3/8 XCK pulse signals. D0 to D7 are 8-bit display data input signals.
2. Driver design
The initialization of the LCD is completed in three steps.
(1) Initialization of I/O ports
Since the PC interface and PD interface of S3C44B0X are used as LCD driver interfaces, it is necessary to set the PC interface to work in the third functional state and the PD interface to work in the second functional state.
(2) Setting method of corresponding control register
S3C44B0X includes an LCD controller timing generator TIMEGEN, which generates VFRAM, VLINE, VCLK and VM control timing. These control signals are configured by registers LCOCON1 and LCDCON2. By setting the configuration items in the registers, TIMEGEN can generate control signals suitable for various LCD screens.
The generation of VFRAM and VLINE pulses is accomplished by configuring the HOZVAL and LINEVAL of the LCDCON2 register. Each domain is related to the size and display mode of the LCD.
Where, HOZVAL=(display width/number of VD data line bits)-1.
In color mode, display width = 3 × number of pixels per line.
For the selected LCD module, HOZVAL=(640×3/8)-1; LINEVAL=(display width)-1.
For the selected LCD module, LlNEVAL=480-1.
The frequency of the VCLK signal can be determined by the CLKVAL field of the LCDCON1 register, that is,
VCLK=MCLK/(CLKVAL×2)
The maximum VCLK frequency of the LCD controller is 16.5MHz, which supports almost all existing LCD drivers. Due to the above relationship, the value of CLKVAL determines the frequency of VCLK. In order to determine the value of CLKVAL, the rate at which the LCD controller transmits data to the VD port should be calculated so that the value of VCLK is greater than the data transmission rate.
The formula for data transfer rate is:
Data transfer rate = HS × VS × FR × MV
Among them, HS is the row pixel value of LCD; VS is the column pixel value of LCD; FR is the frame rate; MV is the mode value, here we take 8-bit single scan, color.
For the selected LCD module: HS=640;VS=480;FR=70Hz:MV=3/8. Therefore, the data transmission rate = 640×480×70×3/8=8,064,000Hz.
The VCLK value should be greater than 8MHz and less than 16MHz, so CLKVAL can be 9 to 15.
(3) Complete LCD initialization procedure
C Program
void LCD_Init_Controler()
{rLCDCON1=(0)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);
//dISAble,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,rLCDCON2=(LINEVAL)|(HOZVAL_COLOR<<10)|(10<<21);
//LINEBLANK=10(without any calculation)
rLCDSADDR1= (0x3<<27) | (((U32)frameBuffer256>>22)<<21)|M5D((U32)frameBuffer256>>1);
//256-color,LCDBANK,LCDBASEU
rLCDSADDR2=M5D((((U32)frameBuffer256+(SCR_XSIZE*LCD_YSIZE))>>1))|(MVAL<<21);
rLCDSADDR3= (LCD_XSIZE/2) | (((SCR_XSIZE-LCD_XSIZE)/2)<<9);
//The following valuehas to be changed forbetter display.
rREDLUT=0xfdb96420;
rGREENLUT=0xfdb96420;
rBLUELUT=0xfb40;
rDITHMODE=0x0;
rDP1_2=0xa5a5;
rDP4_7=0xba5da65;
rDP3_5=0xa5a5f;
rDP2_3=0xd6b;
rDP5_7=0xeb7b5ed;
rDP3_4=0x7dbe;
rDP4_5=0x7ebdf;
rDP6_7=0x7fdfbfe;
rLCDCON1= (1)|(2<<5)|(0<<7)|(0x3<<8)|(0x3<<10)|(4<<12);
}
After the above steps, the hardware driver of the LCD is completed. The next step is to port the software package, call the underlying driver, and complete the complex display task.
3. Porting of uC/GUI software package
3.1 uC/GUI Features
(1) Supports any 8-bit, 16-bit, and 32-bit CPUs, and only requires the CPU to have a corresponding ANSI-C compiler;
(2) All hardware interface definitions use configurable macros;
(3) Characters and bitmaps can be displayed at any point on the LCD, and are not limited to addresses that are integer multiples of the byte length;
(4) All programs are optimized in length and speed and have a clear structure;
(5) For slow LCD controllers, buffer memory can be used to reduce access time and increase display speed.
3.2 uC/GUl transplantation steps
When using uC/GUI, you can follow the steps below:
(1) Customize uC/GUI as needed;
(2) Specify the address of the hardware device and write the interface driver code;
(3) Compile, link, and debug example programs;
(4) Modify the example program and test to add the required functions;
(5) Write your own application.
3.3 Specific Implementation
(1) First, introduce the directory structure and basic configuration of uC/GUI.
The main directories of uC/GUI are as follows:
GUI/ConvertMono Grayscale conversion function to be used when using a black and white display device
GUI/ConvertColor Color conversion function used when using a color display device
GUI/Config contains some files for configuring uC/GUI
GUI/Core uC/GUI core code
GUI/Font uC/GUI and font related code files
GUI/LCDDriver LCD driver code file
GUI/MemDev memory device support file code
GUI/Touch input device supported file codes
GUI/Widget uC/GU1 supports control codes, including edit boxes, list boxes, buttons, and selection boxes.
GUI/WM uC/GUI window management code
(2) Modify uC/GUI to make it suitable for porting.
Create a new project in the ADS environment and add all the files in the above gui folder to the project.
3 files in the Config folder GU IC onf.h,
Add GUITouchConf.h and LCDConf.h to the new project, and modify the content of LCDConf.h as follows:
C Program
/*LCDConf.h*/
#ifndef LCDCONF_H
#define LCDCONF_H
#define LCDG4 // LCD color number, must be defined, LCDMONO (monochrome), LCDG4 (four levels of grayscale), LCDG16 (16 levels of grayscale)
#define LCD_XSIZE(640) /* LCD horizontal resolution*/
#define LCD_YSIZE(480) /* LCD vertical resolution*/
#define LCD BITSPERPIXEL(8)#endif /*LCDC0NF_H*//*The following is the configuration of the S3C44B0X LCD controller*/
#include "..incoption.h"
#define SCR_XSIZE (640) //Window screen size
#define SCR_YSIZE (480) #define LCD_XSIZE (640) //LCD screen size
#define LCD_YSIZE (480)#define M5D(n)((n)&0x1fffff)
#define ARRAY_SIZE_G4(SCR_XSIZE/4*SCR_YSIZE)
#define HOZVAL (LCD_XSIZE/4-1)
#define HOZVAL_COLOR (LCD_XSIZE*3/8-1)
#define LINEVAL (LCD_YSIZE-1)
#define MVAL (13)
#define CLKVAL_G4 (10)
#define MVAL_USED 0
#endif /*LCDCONF_H */
(3) Load LCD driver.
As mentioned above, the LCD driver is saved in lcd44b0.c. In addition to the underlying initialization function LCD_Init_Controler(), the following modifications need to be made, and only the key parts are mentioned here.
It mainly performs related register configuration and interface program with GUI. Only the key parts are mentioned here.
① Define the char data type used when displaying the buffer, which is 8 bits:
unsigned char Bmp[ARRAY_SIZE_G16]; //LCD display buffer array
② The data type used when defining the read and write buffer is also 8-bit U8:
#define LCD_READ_MEM (Off)*((U8*)(frameBuffer256+(((U32)(Off)))))
#define LCD_WRRITE_MEM(Off,data)*((U8*)frameBuffer256+(((U32)(Off)))))=data
#define LCD_WRITE_REG(Off,data)
⑧ Define the LCD bus width as 8 bits:
#ifndef LCD_BUSWIDTH
#define LCD_BUSWIDTH(8)
#endif
④ Define byte order:
#define LCD_SWAP_BYTE_ORDER(0)
So far, the porting of uC/GUI has been basically completed. Of course, only the key parts of the porting are provided here. A more complete porting still requires a lot of work, such as the porting of the touch screen, the porting of the keyboard and mouse , and the porting of Chinese fonts. For details, please refer to the Getting Started chapter in the uC/GUI manual.
4. Data display program design
The data display program is mainly based on the GUI function library of the uC/GUI platform to complete the drawing of characters and curves. The GUI functions related to line drawing are:
GUI DrawHLine()
原型:void GUI_DrawLine(int x0,int y0,int x1,int y1);
Among them, x0, y0, x1, and y1 are the horizontal and vertical coordinates of the starting point and end point in the UGI coordinate system respectively.
GUI DispDec()
原型:void GUI_DispDec(I32 in,U8 Only);
Among them, v is the decimal variable value to be displayed, and Len is the number of digits of the data to be displayed.
5. Summary
This paper mainly introduces the transplantation of uC/GUI based on ARM7 core S3C44B0X and L78C64 LCD module hardware platform, as well as its application in engineering. Through practical application, it is found that uC/GUI is powerful, responsive, stable and has broad application prospects.
Previous article:Comprehensive application of single-chip technology of ARM, FPGA and programmable analog circuit design
Next article:Research on Embedded Network Monitoring System
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- 【GE32E231_DIY】FreeRTOS+DAP_RTT+Multi-function button+USART_DMA and add FREEMODBUS
- 【Industrial Temperature Transmitter Design】Material Unpacking-ADICUP360
- Showing off my products + the Analog Discovery 2 I just got today
- ABB 1756-L81E
- ST introduces an analog microphone IMP23ABSU that can measure ultrasonic waves
- The difference between different versions of TI's ZigBee protocol stack and how to choose the right protocol stack for product development
- [GD32E231 Review] 2. Development insights and chip introduction
- Combining the new 6-axis IMU with DSP to achieve high-performance motion tracking accuracy
- 0 ohm resistor or ferrite bead to isolate digital ground and analog ground?
- Sampling Issues with LTC2325-16