S3C2440-LCD图片显示
时间:03-25
来源:互联网
点击:
折腾了几日,终于可以将图片显示在LCD上了,我使用的东华的WXCAT35-TG3#001 TFT LCD。首先使用PHOTOSHOP软件将图片改成宽320,高240,注意不要反了。然后用Image2Lcd_32软件提取出数组。我选的是24位真彩。所以一个像素3个字节,显示的时候,通过位运算将3个字节合到一起,显示在一个像素上。
Image2Lcd_32的配置方法:
#include "2440addr.h"
#include "picture.h"
//垂直同步信号的脉宽、后肩和前肩
#define VSPW 15
#define VBPD 3
#define VFPD 5
//水平同步信号的脉宽、后肩和前肩
#define HSPW 8
#define HBPD 58
#define HFPD 15
#define CLKVAL 10
#define HOZVAL 319
#define LINEVAL 239
#define PWREN 1
#define MMODE 0
#define PNRMODE 3
#define BPPMODE 13
#define INVVCLK 0
#define INVVD 0
#define INVVDEN 0
#define U32 unsigned int
#define M5D(n) ((n) & 0x1fffff)
#define PAGEWIDTH 320
#define OFFSIZE 0
#define LCD_XSIZE 320
#define LCD_YSIZE 240
#define SCR_XSIZE 320
#define SCR_YSIZE 240
#define INVVLINE 1
#define INVVFRAME 1
#define BPP24BL 0
#define BSWP 0
#define HWSWP 0
volatile U32 LCD_BUFFER[240][320];
void Init_LCD(){
rLCDCON1=(CLKVAL<<8)|(MMODE<<7)|(PNRMODE<<5)|(BPPMODE<<1)|0; //设置CLKVAL,VCLK=HCLK/[(CLKVAL+1)*2],决定VM的触发方式,选择显示模式和BPP模式,暂时不要开启LCD,因为还没有设置好
rLCDCON2=(VBPD<<24)|(LINEVAL<<14)|(VFPD<<6)|(VSPW); //rLCDCON2,rLCDCON3和rLCDCON4主要设置时序
rLCDCON3=(HBPD<<19)|(HOZVAL<<8)|(HFPD);
rLCDCON4=(HSPW);
rLCDCON5 = (BPP24BL<<12) | (INVVCLK<<10) | (INVVLINE<<9) | (INVVFRAME<<8) | (0<<7) | (INVVDEN<<6) | (PWREN<<3) |(BSWP<<1) | (HWSWP); //INVVLINE和INVVFRAME需要进行翻转,因为CPU发出的是正脉冲,LCD使用的是负脉冲,所以要改变极性,PWREN使能电源信号
rLCDSADDR1=(((U32)LCD_BUFFER>>22)<<21)|M5D((U32)LCD_BUFFER>>1);
rLCDSADDR2=M5D(((U32)LCD_BUFFER+(SCR_XSIZE*SCR_YSIZE*4))>>1 );
rLCDSADDR3=PAGEWIDTH*32/16;
rLCDINTMSK|=(3);
rTCONSEL = 0;
rGPCUP = 0x0;
rGPDCON = 0xaaaaaaaa;
rGPCCON = 0xaaaa02a9;
rGPDUP = 0x0;
rGPGUP=rGPGUP&("(1<<4))|(1<<4);
rGPGCON=rGPGCON&("(3<<8))|(3<<8);
rLCDCON1 |= 1; //使能数据输出和LCD控制信号
}
void Paint(unsigned char ch[]){
int y, x, t = 0;
for(y = 0; y < LCD_YSIZE; y++)
for(x = 0; x < LCD_XSIZE; x++){
LCD_BUFFER[y][x] = (ch[t]<<16)|(ch[t+1]<<8)|(ch[t+2]); //因为是24位真彩,所将3个字节赋值到一个像素点上
t = t + 3;
}
}
void Paint_background(U32 c){
unsigned int i, j;
for(j = 0; j < LCD_YSIZE; j++)
for(i = 0; i < LCD_XSIZE; i++)
LCD_BUFFER[j][ i] = c;
}
int LcdMain(){
Init_LCD();
Paint_background(0xFFFFFF);
Paint(picture); //picture是从图片中提取出来的数组
while(1);
}
李万鹏
Image2Lcd_32的配置方法:
#include "2440addr.h"
#include "picture.h"
//垂直同步信号的脉宽、后肩和前肩
#define VSPW 15
#define VBPD 3
#define VFPD 5
//水平同步信号的脉宽、后肩和前肩
#define HSPW 8
#define HBPD 58
#define HFPD 15
#define CLKVAL 10
#define HOZVAL 319
#define LINEVAL 239
#define PWREN 1
#define MMODE 0
#define PNRMODE 3
#define BPPMODE 13
#define INVVCLK 0
#define INVVD 0
#define INVVDEN 0
#define U32 unsigned int
#define M5D(n) ((n) & 0x1fffff)
#define PAGEWIDTH 320
#define OFFSIZE 0
#define LCD_XSIZE 320
#define LCD_YSIZE 240
#define SCR_XSIZE 320
#define SCR_YSIZE 240
#define INVVLINE 1
#define INVVFRAME 1
#define BPP24BL 0
#define BSWP 0
#define HWSWP 0
volatile U32 LCD_BUFFER[240][320];
void Init_LCD(){
rLCDCON1=(CLKVAL<<8)|(MMODE<<7)|(PNRMODE<<5)|(BPPMODE<<1)|0; //设置CLKVAL,VCLK=HCLK/[(CLKVAL+1)*2],决定VM的触发方式,选择显示模式和BPP模式,暂时不要开启LCD,因为还没有设置好
rLCDCON2=(VBPD<<24)|(LINEVAL<<14)|(VFPD<<6)|(VSPW); //rLCDCON2,rLCDCON3和rLCDCON4主要设置时序
rLCDCON3=(HBPD<<19)|(HOZVAL<<8)|(HFPD);
rLCDCON4=(HSPW);
rLCDCON5 = (BPP24BL<<12) | (INVVCLK<<10) | (INVVLINE<<9) | (INVVFRAME<<8) | (0<<7) | (INVVDEN<<6) | (PWREN<<3) |(BSWP<<1) | (HWSWP); //INVVLINE和INVVFRAME需要进行翻转,因为CPU发出的是正脉冲,LCD使用的是负脉冲,所以要改变极性,PWREN使能电源信号
rLCDSADDR1=(((U32)LCD_BUFFER>>22)<<21)|M5D((U32)LCD_BUFFER>>1);
rLCDSADDR2=M5D(((U32)LCD_BUFFER+(SCR_XSIZE*SCR_YSIZE*4))>>1 );
rLCDSADDR3=PAGEWIDTH*32/16;
rLCDINTMSK|=(3);
rTCONSEL = 0;
rGPCUP = 0x0;
rGPDCON = 0xaaaaaaaa;
rGPCCON = 0xaaaa02a9;
rGPDUP = 0x0;
rGPGUP=rGPGUP&("(1<<4))|(1<<4);
rGPGCON=rGPGCON&("(3<<8))|(3<<8);
rLCDCON1 |= 1; //使能数据输出和LCD控制信号
}
void Paint(unsigned char ch[]){
int y, x, t = 0;
for(y = 0; y < LCD_YSIZE; y++)
for(x = 0; x < LCD_XSIZE; x++){
LCD_BUFFER[y][x] = (ch[t]<<16)|(ch[t+1]<<8)|(ch[t+2]); //因为是24位真彩,所将3个字节赋值到一个像素点上
t = t + 3;
}
}
void Paint_background(U32 c){
unsigned int i, j;
for(j = 0; j < LCD_YSIZE; j++)
for(i = 0; i < LCD_XSIZE; i++)
LCD_BUFFER[j][ i] = c;
}
int LcdMain(){
Init_LCD();
Paint_background(0xFFFFFF);
Paint(picture); //picture是从图片中提取出来的数组
while(1);
}
李万鹏
- 采用灵活的汽车FPGA 提高片上系统级集成和降低物料成本(04-28)
- 从LCD电极读数的单片机接口技术(01-15)
- 嵌入式Linux下彩色LCD驱动的设计与实现(03-09)
- 基于FPGA的液晶显示控制器设计(02-17)
- LCD部分专业术语解释(03-06)
- 点阵LCD的驱动显控原理(上册)(03-20)