LCD---We played with mini2440 (arm9) bare metal in those years

Publisher:信息巫师Latest update time:2016-12-28 Source: eefocusKeywords:LCD  mini2440  arm9 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

LCD is the abbreviation of liquid crystal display. Liquid crystal displays are divided into 1. static drive, 2. simple matrix drive and 3. active matrix drive according to the driving mode.

Among them, the simple matrix can be divided into two types: twisted nematic (TN) and super twisted nematic (STN), while the active matrix drive is mainly based on TFT.

 

Both TN and STN use field voltage drive. If the display size increases, the reaction time of the center part to the motor change will become longer, and the display speed cannot keep up. To solve this problem, active matrix drive TFT was proposed. It uses transistor display signals to turn on and off the voltage of liquid crystal molecules, thus avoiding the display's reliance on electric field effects.

 

LCD screen displays images not only need LCD driver, but also LCD controller. Many main chip CPUs integrate LCD controllers.

According to the display principle: as the frame synchronization signal, vsync, each pulse means that a new image data starts to be transmitted. As the line synchronization signal, hsync, each pulse indicates that a new line of image data starts to be sent.

LCD Timing Diagram

All LCDs display images from top to bottom and from left to right. An image can be considered a rectangle, consisting of many neatly arranged pixels in rows, which are called pixels.

VCLK: pixel clock signal

A pulse signal is sent, indicating that a new point of image data begins to be transmitted.

LEND: line end signal

 

Frame Buffer

FrameBuffer is essentially a hardware abstraction of a graphics device. For developers, FrameBuffer is a display buffer. Writing data in a specific format to the display buffer means outputting content to the screen. By continuously writing data to the framebuffer, the display controller automatically retrieves data from the frame buffer and displays it.

In embedded systems, a portion of the main memory is used as video memory; therefore, the essence of the frame buffer is video memory.

 

Frame buffer device

The frame buffer device is a very typical character device. The device file corresponding to the frame buffer device is /dev/fb*. If the system has multiple display cards, Linux can also support multiple frame buffer devices, up to 32, namely /dev/fb0 to /dev/fb31, and /dev/fb0 is the current default frame buffer device, usually pointing to /dev/fb0. The frame buffer device is a standard character device, with a major device number of 29 and a minor device number from 0 to 31.

 

Experimental content:

1. Clear LCD

Use command: dd if=/dev/zero of=/dev/fb0 bs=240 count=320

(dd is used to copy files if (in file) of (out file) bs: block size count:)

Bs=240 means one block is 240 bytes; count=320 means 320 blocks

2. Run the application and draw

./LCD

3. Clear LCD

Use command: dd if=/dev/zero of=/dev/fb0 bs=240 count=320

1. Displaying images

2.     cat   xx.bmp > /dev/fb0

Summary: Through the frame buffer, we can operate the LCD display image, that is, the LCD display image comes from the frame buffer, and /dev/fb0 is the device file of the frame buffer, so operating /dev/fb0 is operating the frame buffer.

 

The platform device classification method is: bus;

Character device classification method: function


  1. #include   

  2.   

  3. #include   

  4.   

  5. #include   

  6.   

  7. #include   

  8.   

  9. #include   

  10.   

  11.    

  12.   

  13. int main () {  

  14.   

  15.     int fp=0;  

  16.   

  17.     struct fb_var_screeninfo vinfo;  

  18.   

  19.     struct fb_fix_screeninfo finfo;  

  20.   

  21.     long screensize=0;  

  22.   

  23.     char *fbp = 0;  

  24.   

  25.     int x = 0, y = 0;  

  26.   

  27.     long location = 0;  

  28.   

  29.     fp = open ("/dev/fb0", O_RDWR); //Open the frame buffer device file  

  30.   

  31.    

  32.   

  33.     if (fp < 0){  

  34.   

  35.         printf("Error : Can not open framebuffer device\n");  

  36.   

  37.         exit(1);  

  38.   

  39.     }  

  40.   

  41.    

  42.   

  43.     if (ioctl(fp,FBIOGET_FSCREENINFO,&finfo)){ //Get some configuration parameters of LCD  

  44.   

  45.         printf("Error reading fixed information\n");  

  46.   

  47.         exit(2);  

  48.   

  49.     }  

  50.   

  51.     if (ioctl(fp,FBIOGET_VSCREENINFO,&vinfo)){  

  52.   

  53.         printf("Error reading variable information\n");  

  54.   

  55.         exit(3);  

  56.   

  57.     }  

  58.   

  59.    

  60.   

  61.     screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; // single frame screen space  

  62.   

  63.     /*This is to map out the contents from the beginning to the screensize size in the file pointed to by fp, and get a pointer to this space*/  

  64.   

  65.     fbp =(char *) mmap (0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fp,0); //Map video memory to process space, fbp is the mapping address  

  66.   

  67.     if ((int) fbp == -1)  

  68.   

  69.     {  

  70.   

  71.          printf ("Error: failed to map framebuffer device to memory.\n");  

  72.   

  73.          exit (4);  

  74.   

  75.     }  

  76.   

  77.     /*This is the position coordinate of the point you want to draw, (0,0) is in the upper left corner of the screen*/  

  78.   

  79.        //Draw a rectangle  

  80.   

  81.     for(x=100;x<150;x++)  

  82.   

  83.    {  

  84.   

  85.         for(y=100;y<150;y++)  

  86.   

  87.        {  

  88.   

  89.              location = x * (vinfo.bits_per_pixel / 8) + y  *  finfo.line_length;  

  90.   

  91.    

  92.   

  93.              *(fbp + location) = 255; /* Blue color depth */ /* Directly assign a value to change the color of a certain point on the screen */  

  94.   

  95.              *(fbp + location + 1) = 0; /* Green color depth*/ /*Note: These values ​​are set for four bytes per pixel. If it is set for 2 bytes per pixel, */  

  96.   

  97.              *(fbp + location + 2) = 0; /* Red color depth*/ /* For example, RGB565 needs to be converted*/  

  98.   

  99.              *(fbp + location + 3) = 0; /* Is it transparent? */   

  100.   

  101.          }   

  102.   

  103.     }  

  104.   

  105.     munmap (fbp, screensize); /*Remove mapping*/  

  106.   

  107.     close (fp); /*close the file*/  

  108.   

  109.     return 0;  

  110.   

  111.    

  112.   

  113. }  



Keywords:LCD  mini2440  arm9 Reference address:LCD---We played with mini2440 (arm9) bare metal in those years

Previous article:Compile the driver into the kernel
Next article:Mmap device method---We played with embedded drivers in those years

Recommended ReadingLatest update time:2024-11-15 17:46

PIC16F72 microcontroller controls HT1621B to drive LCD
//PIC 16C72 MCU  controls  HT1621B to drive LCD #include pic.h #define BIAS 0X50 //1/2 bias, 4 back pole #define RC256 0X30 //System clock selects the on-chip RC oscillator #define WDTDIS1 0X0A //Disable WDT overflow flag output #define TIMERDIS 0X08 //Time base output disable #define SYSEN 0X02 //Turn on the syste
[Microcontroller]
MCU waveform generator source code
Program source code #include reg51.h #include intrins.h #include math.h #define  uchar  unsigned  char #define  uint  unsigned   int unsigned long Result,i; sbit SDA=P1^1; //PCF8591  interface sbit SCL=P1^0; unsigned int a=0; // waveform sampling point value unsigned int b=0; unsigned  int c=0; unsigned  int bx_
[Microcontroller]
MCU waveform generator source code
mini2440-i2c driver analysis
In the i2c driver framework of s3c2440, there are two parts, one is i2c-adapter initialization, the other is i2c-driver initialization. For the eeprom that comes with s3c2440, read the code to see what is worth learning and reference. There are several i2c-adapters on s3c2440, each corresponding to an i2c bus. Multi
[Microcontroller]
mini2440-i2c driver analysis
IAR For AVR -- LCD1602
The ports of LCD1602 are mostly the same, so I won't go into details here. You can look for the datasheet of Changsha Sunman. Below is the program. The definition is very obvious in the program. It should be noted that the backlight is controlled by a transistor, but the effect is not very good. It is worse than conne
[Microcontroller]
Update LCD data via PIC microcontroller
  To update the LCD, the contents of the LCDDATA register can be modified to light or unlight each pixel on the LCD display. The application firmware typically creates modifications to buffer variables that correspond to elements on the display (e.g., character positions, bar graphs, battery displays, etc.).   When th
[Microcontroller]
LCD1602 four-wire programming method program design example
The first time I adjusted the 4-line LCD 1602, it was quite difficult, either because of the wrong delay or the wrong command. It took me a whole day to get the 4-line 1602 programming implementation. Here are the programs for 51 MCU and LPC23XX series MCU. I found the 51 program on the Internet. You can refer to the
[Microcontroller]
Panasonic disbands LCD subsidiary and moves into electric vehicle battery market
According to news on August 1, Japanese electronics giant Panasonic announced on Monday that it will liquidate its subsidiary that produces liquid crystal displays ( LCDs ) to accelerate its transformation into electric vehicle (EV) battery manufacturing. Panasonic LCD Co., Ltd., based in Himeji City near Osaka,
[Automotive Electronics]
Panasonic disbands LCD subsidiary and moves into electric vehicle battery market
Single chip real-time clock circuit (LCD1602, DS1302)
1. Introduction This circuit mainly consists of 51 single-chip microcomputer, LCD1602 module and DS1302 chip, and displays the current time through LCD1062. 2. Operation Effect 3. Source Files main.c /*Want more projects private wo!!!*/ #include reg52.h #include intrins.h #include string.h #define uint unsign
[Microcontroller]
Single chip real-time clock circuit (LCD1602, DS1302)
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号