s3c2440 lcd display picture bare metal program

Publisher:科技飞翔Latest update time:2023-09-04 Source: elecfansKeywords:s3c2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Because the previous bare metal program is very simple, I won’t blog about it.


Program flow:


1. Initialize C SP 


2. Turn off the watchdog


3. Initialize SDRAM


4. Read the program containing pictures in NAND FLASH and put it into SDRAM.


5. Jump to SDRAM for execution


Because the 2440 automatically only reads 4K to SRAM, if you put pictures in it, it will naturally not be enough. It's just one more step to put it in SDRAM.


I didn't directly copy the program in the tutorial, that one is more complicated. C library files are used. 


In the tutorial, we just draw lines, and drawing circular lines is very simple.


At the beginning, I used 24BPP to develop, so I encountered many problems.


The picture needs to be converted into a C language header file. I see that there are many people on the Internet looking for software to convert, and there is also one who uses C to convert under LINUX. I looked for a software, it was made by MFC, but it didn't support 24BPP. 


I can only do it myself. Written in python. The link is here: http://www.cnblogs.com/ningci/p/5203053.html


16BPP:


//lcd controller

typedef struct{

    unsigned long LCDCON1;

    unsigned long LCDCON2;

    unsigned long LCDCON3;

    unsigned long LCDCON4;

    unsigned long LCDCON5;

    unsigned long LCDSADDR1;

    unsigned long LCDSADDR2;

    unsigned long LCDSADDR3;

    unsigned long REDLUT;

    unsigned long GREENLUT;

    unsigned long BLUELUT;

    unsigned long DITHMODE;

    unsigned long TPAL;

} LCD;


LCD * lcd = (LCD *)0x4d000000;


#define GPBCON (*(volatile unsigned long *)0x56000010)

#define GPBDAT (*(volatile unsigned long *)0x56000014)

#define GPCUP (*(volatile unsigned long *)0x56000028)

#define GPCCON (*(volatile unsigned long *)0x56000020)

#define GPDUP (*(volatile unsigned long *)0x56000038)

#define GPDCON (*(volatile unsigned long *)0x56000030)

#define GPGUP (*(volatile unsigned long *)0x56000068)

#define GPGCON (*(volatile unsigned long *)0x56000060)

#define HCLK 100000000

#define LCD_WIDTH 480

#define LCD_HEIGHT 272

#define LCD_CLKVAL 4

#define LCD_TFT 3

#define LCD_24BBP 0xd

#define LCD_16BBP 0xc

#define LCD_EN_OFF 0

#define LCD_EN_ON 1

#define LCD_VBPD 1

#define LCD_LINEVAL (LCD_HEIGHT - 1)

#define LCD_VFPD 1

#define LCD_VSPW 9

#define LCD_HBPD 1

#define LCD_HOZVAL (LCD_WIDTH - 1)

#define LCD_HFPD 1

#define LCD_HSPW 40

#define LCD_INVVLINE 1

#define LCD_INVVFRAME 1

#define LCD_FRAMEBUFFER 0x30400000 //4M aligned address

 

void wait(s)

{

    while(s--);

}



void init_lcd()

{

    //LCD_PWREN

    GPGUP = 0xffffffff; // Disable internal pull-up

    GPGCON = 3<<8;

    

    GPCUP = 0xffffffff; // Disable internal pull-up

    GPCCON = 0xaaaaaaaa; // GPIO pins for VD[7:0], LCDVF[2:0], VM, VFRAME, VLINE, VCLK, LEND 

    GPDUP = 0xffffffff; // Disable internal pull-up

    GPDCON = 0xaaaaaaaa; // GPIO pins for VD[23:8]

    //GPB0 KEYBOARD

    //backlight on

    GPBCON &= ~(3);

    GPBCON |= 1;

    //HCLK 100M LCD CLK 9M 100/9/2-1=4

    //The default is not enabled

    lcd->LCDCON1 = LCD_CLKVAL<<8 | LCD_TFT<<5 | LCD_16BBP<<1 | LCD_EN_OFF;

    lcd->LCDCON2 = LCD_VBPD<<24 | LCD_LINEVAL<<14 | LCD_VFPD<<6 | LCD_VSPW;

    lcd->LCDCON3 = LCD_HBPD<<19 | LCD_HOZVAL<<8 | LCD_HFPD;

    lcd->LCDCON4 = LCD_HSPW;

    //8bpp BSWP 1 16bpp HWSWP 1 24bpp 0 0 

    lcd->LCDCON5 = 1<<11 | LCD_INVVLINE<<9 | LCD_INVVFRAME<<8 | 1;

    //The address is stored separately and the 31:22 bits can be shifted to the right. The 21:1 bits are used & the upper 21 1s are cleared if the high bit is not 7.

    lcd->LCDSADDR1 = (LCD_FRAMEBUFFER>>22)<<21 | ((LCD_FRAMEBUFFER>>1) & 0x1fffff);

    //24bpp occupies 4 lengths of 16bpp, 2 lengths of 8bpp and 1 length 

    lcd->LCDSADDR2 = ((LCD_FRAMEBUFFER + LCD_WIDTH * LCD_HEIGHT*2)>>1) & 0x1fffff;

    lcd->LCDSADDR3 = LCD_WIDTH;

    lcd->TPAL = 0;

}


void lcd_on()

{

    //backlight on

    GPBDAT |= 1;

    lcd->LCDCON1 |= LCD_EN_ON;

    lcd->LCDCON5 |= 0x3<<2;

}


void lcd_off()

{

    //Backlight off

    GPBDAT &= 0;

    lcd->LCDCON1 &= LCD_EN_OFF;

    lcd->LCDCON5 &= ~(0x3<<2);

}


void show_img(unsigned short *img)

{

    int i=0;

    //Video memory address

    unsigned short * frame_buf = (volatile unsigned short *)LCD_FRAMEBUFFER;

    for(i=0;i<(480*272);i++)

    {

        *frame_buf = *img;

        frame_buf++;

        img++;

    }

}


#include "img1.h"

int main()

{

    init_lcd();

    lcd_on();

    show_img(&img1);

    return 0;

}


Just write the color value directly into the memory and display it on the screen.


The following is the display rendering:

 


Keywords:s3c2440 Reference address:s3c2440 lcd display picture bare metal program

Previous article:Compile busybox-1.24.1 and create a file system
Next article:ARM WIFI AP mode uses iptables nat forwarding to access the Internet through LAN cable

Recommended ReadingLatest update time:2024-11-16 07:51

FFmpeg video encoding library S3C2440 porting
FFmpeg is an open source, free, cross-platform video and audio streaming solution. It is free software and uses the LGPL or GPL license (depending on the components you choose). It provides a complete solution for recording, converting, and streaming audio and video. It contains a very advanced audio/video codec lib
[Microcontroller]
S3C2440⑥ | UART Experiment
Experiment - UART data transmission and reception experiment 1. Look at the schematic to determine how the UART hardware is connected As can be seen from the schematic diagram, the three serial ports on the JZ2440 development board are all brought out, among which UART0 is equipped with an onbo
[Microcontroller]
S3C2440⑥ | UART Experiment
s3c2440 bare metal-nandflash programming (1. Introduction to nandflash principle and structure)
1.The schematic diagram of nandflash is as follows: The pin attributes are shown in the table below: Pin name Pin function 100~107 Data input and output (command, address, data share data bus) CLE Command enable BUT Address enable /THIS Chip enable (chip select) /RE Read enable /WE Write enable R/B Ready/
[Microcontroller]
s3c2440 bare metal-nandflash programming (1. Introduction to nandflash principle and structure)
ARM9 embedded processor S3C2440 implements a remote image light monitoring system
  For image surveillance systems, users often put forward such functional requirements: they hope to be able to monitor distant objects. These objects may be distributed in suburbs, deep mountains, wastelands or other unattended places; in addition, they hope to obtain relatively clear surveillance images. , but it is
[Microcontroller]
ARM9 embedded processor S3C2440 implements a remote image light monitoring system
Design of press-fit data acquisition system based on S3C2440 chip and microcontroller
introduction With the development of economy and society, my country's industrial level and information technology level have also developed rapidly. Among them, the most common parts assembly and equipment press-fit monitoring equipment in the industry have also been continuously improved. The process of press-fittin
[Microcontroller]
Design of press-fit data acquisition system based on S3C2440 chip and microcontroller
S3C2440 UDA1341 sound card driver analysis (oos)
1. Driver architecture: The driver is divided into two levels, the upper level is the platform device driver, and the lower level is the audio driver and mixer driver. (1) Standard platform device driver structure, probe and remove functions. Probe: Get platform resources- Apply for memory area-io
[Microcontroller]
s3c2440 bare metal-bss clearing principle and implementation
1. Introduction of bss clearing (why we need to clear bss) Let’s give an example first: #include "s3c2440_soc.h" #include "uart.h" char g_Char = 'A'; //.data char g_Char3 = 'a'; const char g_Char2 = 'B'; //.rodata int g_A = 0; //bss int g_B; //bss int main(void) { uart0_init(); puts("nrg_A = "); printHex(g_
[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号