共2条
1/1 1 跳转至页
S3C44B0X,G35LCD 【求助】S3C44B0X,G35LCD驱动程序出问题,大家帮忙看看
问
S3C44B0X,G35LCD(320*240,彩色)
(一)先看程序是这样的如下:
/*文件:OPTION.H*/
#define MCLK 60000000
/*文件:LCDLIB.H */
#define MODE_COLOR (256)
#define HOZVAL_COLOR (LCD_SIZE*3/8-1)
#define SCR_XSIZE (640)
#define SCR_YSIZE (480)
#define LCD_XSIZE (320)
#define LCD_YSIZE (240)
#define ARRAY_SIZE_COLOR (SCR_XSIZE/1*SCR_YSIZE)
#define MVAL (13)
#define CLKVAL_COLOR (10)
#define MVAL_USED 0
extern unsigned int (*frameBuffer256)[SCR_XSIZE/4];
……
void Lcd_Init(int depth);
void Lcd_DispON(void);
void Lcd_DispOFF(void);
void Lcd_Display(void);
……
/*文件:44BLIB.C ***
*函数:Port_Init()**/
void Port_Init()
{
……
//PORT C GROUP
//BUSWIDTH=16
//PORT C GROUP
//rPCONC[31:0]
//|GPC15|.............................................GPC5GPC4...............| GPC0
//|BIT31|....................................................................| BIT0
//|nCTS0|nRTS0|RXD1|TXD1|nCTS1|nRTS1|nEL|nDISP|VD4|VD6| | |LED2|LED1|LED0|D12SUSPD
//| 00| 00| 11| 11| 00| 00| 01| 01| 11| 11| 01| 01| 01| 01| 01| 01
//rPUPC[15:0]
//| 0| 0| 1| 1| 0| 0| 0| 0| 1| 1| 0| 0| 0| 0| 0| 0
rPDATC=0xffff; //All I/O Is High
rPCONC=0x0f05f555;
rPUPC=0x30c0; //PULL UP RESISTOR should be enabled to I/O
//PORT D GROUP
//rPCOND
//| BIT15|.........................|BIT0
//|VFRAME|VM|VLINE|VCLK|VD3|VD2|VD1|VD0
//| 10|10| 10| 10| 10| 10| 10| 10
rPDATD=0xff;
rPCOND=0xaaaa;
rPUPD=0xff;
……
}
/* 文件:LCDLIB.C */
……
#include "..\inc\lcdlib.h"
……
unsigned int (*frameBuffer256)[SCR_XSIZE/4];
void Lcd_Init(int depth)
{
switch(depth)
{
case 1:
……
break;
case 4:
……
break;
/* 256 MODE_COLOR */
case 256:
if((U32)frameBuffer256==0)
{
//The total frame memory should be inside 4MB.
//For example, if total memory is 8MB, the frame memory
//should be in 0xc000000~0xc3fffff or c400000~c7fffff.
//But, the following code doesn't meet this condition(4MB)
//if the code size & location is changed..
frameBuffer256=(unsigned int (*)[SCR_XSIZE/4])malloc(ARRAY_SIZE_COLOR);
}
rLCDCON1=(0)|(2<<5)|(MVAL_USED<<7)|(0x1<<8)|(0x1<<10)|(CLKVAL_COLOR<<12);
// disable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
rLCDCON2=(LINEVAL)|(HOZVAL<<10)|(10<<21);
//LINEBLANK=10 (without any calculation)
// rLCDSADDR1= (0x3<<27) | ( ((U32)frameBuffer256>>22)<<21 ) | M5D((U32)frameBuffer256>>1);
rLCDSADDR1= (0x3<<27) | ( ((U32)frameBuffer256>>22)<<21 ) | 0x0;
// 256-color, LCDBANK, LCDBASEU
// rLCDSADDR2= M5D((((U32)frameBuffer256+(SCR_XSIZE*LCD_YSIZE))>>1)) | (MVAL<<21);
rLCDSADDR2= (0)<<29|(0)<<21|((320/16+(640-320)/16)*240);
rLCDSADDR3= (LCD_XSIZE/2) | ( ((SCR_XSIZE-LCD_XSIZE)/2)<<9 );
//The following value has to be changed for better 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)|(MVAL_USED<<7)|(0x1<<8)|(0x1<<10)|(CLKVAL_COLOR<<12);
break;
default:
break;
}
}
void Lcd_Display(void)
{
int i,j;
for(j=0;j<240;j++)
for(i=0;i<20;i++)
{
//frameBuffer4[j][i]=(girl[i*4+0])<<24
// +(girl[i*4+1])<<16
// +(girl[i*4+2])<<8
// +(girl[i*4+3]);
frameBuffer256[j][i]=0xffff0000;
}
}
void Lcd_DispON(void)
{
Delay(5000);
rPDATC = ( rPDATC & (~(1<<8)) );
Delay(5000);
}
void Lcd_DispOFF(void)
{
Delay(5000);
rPDATC = ( rPDATC | (1<<8) );
Delay(5000);
}
/* 文件:Main.c */
void Main(void)
{
int i;
char aa;
rSYSCFG=CACHECFG; // Using 8KB Cache//
pISR_SWI=(_ISR_STARTADDRESS+0xf0); //for pSOS
Port_Init();
Isr_Init();
Uart_Init(0,57600);
Uart_Select(0); //Select UART0
Uart_Printf("\n*********** start to test lcd *************\n");
Uart_Printf("\n*********** press any to start Lcd_Init()************\n");
Uart_Getch();
Lcd_Init(MODE_COLOR); //Init Lcd
Uart_Printf("\n******* Lcd_Init() success,press any key********\n");
Uart_Getch();
Uart_Printf("\n******* press any key to test Lcd_DispON() ********\n");
Uart_Getch();
Lcd_DispON();
Uart_Printf("\n******* Lcd_DispON() sucess,press any key ********\n");
Uart_Getch();
Uart_Printf("\n******* press any key to test Display() ********\n");
Uart_Getch();
Lcd_Display();
Uart_Printf("\n******* Display() success,press any key********\n");
Uart_Getch();
Uart_Printf("\n******* press any key to test Lcd_DispOFF() ********\n");
Uart_Getch();
Lcd_DispOFF();
Uart_Printf("\n******* Lcd_DispOFF() success,press any key********\n");
Uart_Getch();
return;
(二)问题
大家先看看上面程序有没有问题。
问题:在Main()里,如果屏蔽Lcd_Display()即:
//Lcd_Display()
则正常运行
如果不屏蔽Lcd_Display()则当运行该函数时,板子就被复位了。
不知道是不是frameBuffer256的问题?我是初学者弄了半天,不明白,帮帮忙。
答 1: 原文件如下上面是被改动的,原文件如下(即被改过的地方):
/* 文件:lcdlib.c */
rLCDCON1=(0)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);
// disable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
//被改为:rLCDCON1=(0)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);
rLCDSADDR1= (0x3<<27) | ( ((U32)frameBuffer256>>22)<<21 ) | M5D((U32)frameBuffer256>>1);
// 256-color, LCDBANK, LCDBASEU
//被改为:rLCDSADDR1= (0x3<<27) | ( ((U32)frameBuffer256>>22)<<21 ) | 0x0;
rLCDSADDR2= M5D((((U32)frameBuffer256+(SCR_XSIZE*LCD_YSIZE))>>1)) | (MVAL<<21);
//被改为:rLCDSADDR2= (0)<<29|(0)<<21|((320/16+(640-320)/16)*240);
rLCDCON1=(1)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);
// enable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
//被改为:rLCDCON1=(1)|(2<<5)|(MVAL_USED<<7)|(0x1<<8)|(0x1<<10)|(CLKVAL_COLOR<<12);
/* 文件:44BLIB.C *
* 函数:Port_Init() */
void Port_Init()
{
……
rPCONC=0x0ffffff;
//被改为:rPCONC=0x0f05f555;
rPUPC=0x3000; //PULL UP RESISTOR should be enabled to I/O
//被改为rPUPC=0x30c0;
rPCOND= 0x8aaa;
//被改为:rPCOND=0xaaaa;
rPUPD = 0xbf;
//被改为:rPUPD=0xff;
……
}
(一)先看程序是这样的如下:
/*文件:OPTION.H*/
#define MCLK 60000000
/*文件:LCDLIB.H */
#define MODE_COLOR (256)
#define HOZVAL_COLOR (LCD_SIZE*3/8-1)
#define SCR_XSIZE (640)
#define SCR_YSIZE (480)
#define LCD_XSIZE (320)
#define LCD_YSIZE (240)
#define ARRAY_SIZE_COLOR (SCR_XSIZE/1*SCR_YSIZE)
#define MVAL (13)
#define CLKVAL_COLOR (10)
#define MVAL_USED 0
extern unsigned int (*frameBuffer256)[SCR_XSIZE/4];
……
void Lcd_Init(int depth);
void Lcd_DispON(void);
void Lcd_DispOFF(void);
void Lcd_Display(void);
……
/*文件:44BLIB.C ***
*函数:Port_Init()**/
void Port_Init()
{
……
//PORT C GROUP
//BUSWIDTH=16
//PORT C GROUP
//rPCONC[31:0]
//|GPC15|.............................................GPC5GPC4...............| GPC0
//|BIT31|....................................................................| BIT0
//|nCTS0|nRTS0|RXD1|TXD1|nCTS1|nRTS1|nEL|nDISP|VD4|VD6| | |LED2|LED1|LED0|D12SUSPD
//| 00| 00| 11| 11| 00| 00| 01| 01| 11| 11| 01| 01| 01| 01| 01| 01
//rPUPC[15:0]
//| 0| 0| 1| 1| 0| 0| 0| 0| 1| 1| 0| 0| 0| 0| 0| 0
rPDATC=0xffff; //All I/O Is High
rPCONC=0x0f05f555;
rPUPC=0x30c0; //PULL UP RESISTOR should be enabled to I/O
//PORT D GROUP
//rPCOND
//| BIT15|.........................|BIT0
//|VFRAME|VM|VLINE|VCLK|VD3|VD2|VD1|VD0
//| 10|10| 10| 10| 10| 10| 10| 10
rPDATD=0xff;
rPCOND=0xaaaa;
rPUPD=0xff;
……
}
/* 文件:LCDLIB.C */
……
#include "..\inc\lcdlib.h"
……
unsigned int (*frameBuffer256)[SCR_XSIZE/4];
void Lcd_Init(int depth)
{
switch(depth)
{
case 1:
……
break;
case 4:
……
break;
/* 256 MODE_COLOR */
case 256:
if((U32)frameBuffer256==0)
{
//The total frame memory should be inside 4MB.
//For example, if total memory is 8MB, the frame memory
//should be in 0xc000000~0xc3fffff or c400000~c7fffff.
//But, the following code doesn't meet this condition(4MB)
//if the code size & location is changed..
frameBuffer256=(unsigned int (*)[SCR_XSIZE/4])malloc(ARRAY_SIZE_COLOR);
}
rLCDCON1=(0)|(2<<5)|(MVAL_USED<<7)|(0x1<<8)|(0x1<<10)|(CLKVAL_COLOR<<12);
// disable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
rLCDCON2=(LINEVAL)|(HOZVAL<<10)|(10<<21);
//LINEBLANK=10 (without any calculation)
// rLCDSADDR1= (0x3<<27) | ( ((U32)frameBuffer256>>22)<<21 ) | M5D((U32)frameBuffer256>>1);
rLCDSADDR1= (0x3<<27) | ( ((U32)frameBuffer256>>22)<<21 ) | 0x0;
// 256-color, LCDBANK, LCDBASEU
// rLCDSADDR2= M5D((((U32)frameBuffer256+(SCR_XSIZE*LCD_YSIZE))>>1)) | (MVAL<<21);
rLCDSADDR2= (0)<<29|(0)<<21|((320/16+(640-320)/16)*240);
rLCDSADDR3= (LCD_XSIZE/2) | ( ((SCR_XSIZE-LCD_XSIZE)/2)<<9 );
//The following value has to be changed for better 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)|(MVAL_USED<<7)|(0x1<<8)|(0x1<<10)|(CLKVAL_COLOR<<12);
break;
default:
break;
}
}
void Lcd_Display(void)
{
int i,j;
for(j=0;j<240;j++)
for(i=0;i<20;i++)
{
//frameBuffer4[j][i]=(girl[i*4+0])<<24
// +(girl[i*4+1])<<16
// +(girl[i*4+2])<<8
// +(girl[i*4+3]);
frameBuffer256[j][i]=0xffff0000;
}
}
void Lcd_DispON(void)
{
Delay(5000);
rPDATC = ( rPDATC & (~(1<<8)) );
Delay(5000);
}
void Lcd_DispOFF(void)
{
Delay(5000);
rPDATC = ( rPDATC | (1<<8) );
Delay(5000);
}
/* 文件:Main.c */
void Main(void)
{
int i;
char aa;
rSYSCFG=CACHECFG; // Using 8KB Cache//
pISR_SWI=(_ISR_STARTADDRESS+0xf0); //for pSOS
Port_Init();
Isr_Init();
Uart_Init(0,57600);
Uart_Select(0); //Select UART0
Uart_Printf("\n*********** start to test lcd *************\n");
Uart_Printf("\n*********** press any to start Lcd_Init()************\n");
Uart_Getch();
Lcd_Init(MODE_COLOR); //Init Lcd
Uart_Printf("\n******* Lcd_Init() success,press any key********\n");
Uart_Getch();
Uart_Printf("\n******* press any key to test Lcd_DispON() ********\n");
Uart_Getch();
Lcd_DispON();
Uart_Printf("\n******* Lcd_DispON() sucess,press any key ********\n");
Uart_Getch();
Uart_Printf("\n******* press any key to test Display() ********\n");
Uart_Getch();
Lcd_Display();
Uart_Printf("\n******* Display() success,press any key********\n");
Uart_Getch();
Uart_Printf("\n******* press any key to test Lcd_DispOFF() ********\n");
Uart_Getch();
Lcd_DispOFF();
Uart_Printf("\n******* Lcd_DispOFF() success,press any key********\n");
Uart_Getch();
return;
(二)问题
大家先看看上面程序有没有问题。
问题:在Main()里,如果屏蔽Lcd_Display()即:
//Lcd_Display()
则正常运行
如果不屏蔽Lcd_Display()则当运行该函数时,板子就被复位了。
不知道是不是frameBuffer256的问题?我是初学者弄了半天,不明白,帮帮忙。
答 1: 原文件如下上面是被改动的,原文件如下(即被改过的地方):
/* 文件:lcdlib.c */
rLCDCON1=(0)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);
// disable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
//被改为:rLCDCON1=(0)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);
rLCDSADDR1= (0x3<<27) | ( ((U32)frameBuffer256>>22)<<21 ) | M5D((U32)frameBuffer256>>1);
// 256-color, LCDBANK, LCDBASEU
//被改为:rLCDSADDR1= (0x3<<27) | ( ((U32)frameBuffer256>>22)<<21 ) | 0x0;
rLCDSADDR2= M5D((((U32)frameBuffer256+(SCR_XSIZE*LCD_YSIZE))>>1)) | (MVAL<<21);
//被改为:rLCDSADDR2= (0)<<29|(0)<<21|((320/16+(640-320)/16)*240);
rLCDCON1=(1)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);
// enable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
//被改为:rLCDCON1=(1)|(2<<5)|(MVAL_USED<<7)|(0x1<<8)|(0x1<<10)|(CLKVAL_COLOR<<12);
/* 文件:44BLIB.C *
* 函数:Port_Init() */
void Port_Init()
{
……
rPCONC=0x0ffffff;
//被改为:rPCONC=0x0f05f555;
rPUPC=0x3000; //PULL UP RESISTOR should be enabled to I/O
//被改为rPUPC=0x30c0;
rPCOND= 0x8aaa;
//被改为:rPCOND=0xaaaa;
rPUPD = 0xbf;
//被改为:rPUPD=0xff;
……
}
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
与电子爱好者谈读图四被打赏50分 | |
与电子爱好者谈读图二被打赏50分 | |
【FRDM-MCXN947评测】Core1适配运行FreeRtos被打赏50分 | |
【FRDM-MCXN947评测】双核调试被打赏50分 | |
【CPKCORRA8D1B评测】---移植CoreMark被打赏50分 | |
【CPKCORRA8D1B评测】---打开硬件定时器被打赏50分 | |
【FRDM-MCXA156评测】4、CAN loopback模式测试被打赏50分 | |
【CPKcorRA8D1评测】--搭建初始环境被打赏50分 | |
【FRDM-MCXA156评测】3、使用FlexIO模拟UART被打赏50分 | |
【FRDM-MCXA156评测】2、rt-thread MCXA156 BSP制作被打赏50分 |