它娘的,终于搞定了,这狗日的供应商,给我的是一个坏屏幕。。。。
贴出源程序,SCLK为100MHZ,TFT‘DCLK为33.3MHZ...
#define lcd_c
#include <cdefBF532.h>
#include <ccblkfn.h>
#include <sys\exception.h>
#include <math.h>
#include <signal.h>
#include <stdlib.h>
#include "public.h"
#include "lcd.h"
section("sdram0_bank1") unsigned char DisplayBuffer[vs_pnt][hs_pnt*3];
section("sdram0_bank1") unsigned char DisplayBuffer_565[vs_pnt][hs_pnt*3];
void LCD_Init(void)
{
InitDMA();
InitPPI();
InitTimer();
PPI_TMR_DMA_Enable();
}
void InitDMA(void)
{
*pDMA0_START_ADDR = &DisplayBuffer_565[0][0];
*pDMA0_X_COUNT = hs_pnt;
*pDMA0_X_MODIFY = 2;
*pDMA0_Y_COUNT = vs_pnt;
*pDMA0_Y_MODIFY = 2;
*pDMA0_CONFIG = 0x1034;
}
void InitPPI(void)
{
*pPPI_CONTROL = 0x781e;
*pPPI_DELAY = 10;
//*pPPI_COUNT = hs_pnt_blank-1;
*pPPI_COUNT = hs_pnt-1;
*pPPI_FRAME = vs_pnt;
}
void InitTimer(void)
{
*pTIMER1_PERIOD = hs_pnt_blank;
*pTIMER1_WIDTH = 35;
*pTIMER1_CONFIG = 0x00a9;
*pTIMER2_PERIOD = hs_pnt_blank*vs_pnt_blank;
*pTIMER2_WIDTH = hs_pnt_blank*10;
*pTIMER2_CONFIG = 0x00a9;
}
void PPI_TMR_DMA_Enable(void)
{
*pDMA0_CONFIG |= 0x1;
asm("ssync;");
InitTimer();
*pPPI_CONTROL |= 0x1;
asm("ssync;");
*pTIMER_ENABLE|= 0x0006;
asm("ssync;");
}
void PPI_TMR_DMAR_Disable(void)
{
*pDMA0_CONFIG &= (~0x1);
*pPPI_CONTROL &= (~0x1);
}
/*
void bgrtorgb24(void)
{
int i,j;
int a,b,c;
for(i=0;i<272;i++)
{
for(j=0;j<1440;j++)
{
TempBuffer_img[i][j] = Inputdata[i*1440+j+54];
}
}
for(i=0;i<272;i++)
{
for(j=0;j<480;j++)
{
a = TempBuffer_img[i][j*3];
b = TempBuffer_img[i][j*3+1];
c = TempBuffer_img[i][j*3+2];
TempBuffer_img[i][j*3] = c;
TempBuffer_img[i][j*3+1] = b;
TempBuffer_img[i][j*3+2] = a;
}
}
for(i=0;i<272;i++)
{
for(j=0;j<1440;j++)
{
DisplayBuffer[i][j] = (TempBuffer_img[271-i][j]);
}
}
}
*/
void COLOR_Bar(void)
{
int i,j;
for(i=0;i<480;i++)
{
for(j=0;j<80;j++)
{
DisplayBuffer[i][j*3+0] = 0x00;
DisplayBuffer[i][j*3+1] = 0x00;
DisplayBuffer[i][j*3+2] = 0xff;
}
for(j=80;j<160;j++)
{
DisplayBuffer[i][j*3+0] = 0xff;
DisplayBuffer[i][j*3+1] = 0x00; DisplayBuffer[i][j*3+1] = 0x00;
DisplayBuffer[i][j*3+2] = 0x00;//red
}
for(j=160;j<240;j++)
{
DisplayBuffer[i][j*3+0] = 0x00;
DisplayBuffer[i][j*3+1] = 0xff;
DisplayBuffer[i][j*3+2] = 0x00;//green
}
for(j=240;j<320;j++)
{
DisplayBuffer[i][j*3+0] = 0x00;
DisplayBuffer[i][j*3+1] = 0x00;
DisplayBuffer[i][j*3+2] = 0xff;//blue
}
for(j=320;j<400;j++)
{
DisplayBuffer[i][j*3+0] = 0xff;
DisplayBuffer[i][j*3+1] = 0xff;
DisplayBuffer[i][j*3+2] = 0x0;//red+green
}
for(j=400;j<480;j++)
{
DisplayBuffer[i][j*3+0] = 0x00;
DisplayBuffer[i][j*3+1] = 0xff;
DisplayBuffer[i][j*3+2] = 0xff;//red+blue
}
for(j=480;j<560;j++)
{
DisplayBuffer[i][j*3+0] = 0xff;
DisplayBuffer[i][j*3+1] = 0x00;
DisplayBuffer[i][j*3+2] = 0xff;//green+blue
}
for(j=560;j<640;j++)
{
DisplayBuffer[i][j*3+0] = 0xff;
DisplayBuffer[i][j*3+1] = 0xff;
DisplayBuffer[i][j*3+2] = 0xff;
}
for(j=640;j<720;j++)
{
DisplayBuffer[i][j*3+0] = 0x00;
DisplayBuffer[i][j*3+1] = 0xff;
DisplayBuffer[i][j*3+2] = 0x00;//green
}
for(j=720;j<800;j++)
{
DisplayBuffer[i][j*3+0] = 0xff;
DisplayBuffer[i][j*3+1] = 0x00;
DisplayBuffer[i][j*3+2] = 0;//blue
}
}
}
void RGB888_RGB565(unsigned char *src, int src_len, unsigned char *dst)
{
int i = 0;
int j = 0;
if (src_len % 3 != 0)
{
return;
}
for (i = 0; i < src_len; i += 3)
{
dst[j] = src[i] >> 3; // B
dst[j] |= ((src[i+1] & 0x07) << 5); // G
dst[j+1] = src[i+2] & 0xF8; // R
dst[j+1] |= (src[i+1] >> 5); // G
j += 2;
}
}
#undef lcd_c