lpcware

LCD 7 Inch and EMC Buffer

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by hamidrm on Sat Sep 13 15:03:20 MST 2014
Hi
I have two problem with my LCD 7 inch working. I m using LPC1788. I locate 2 buffer for lcd 7 inch at K4S561632C memory. a buffer for current show and a  wait buffer for drawing. I am using double buffer to make fast drawing images and make immediately drawing.
I used from DMA to copying data in buffers. but DMA need some delay to done copying successfully.

void SwapBuffer(){
LPC_LCD->UPBASE = (VIDEOWAITBUFFER_BASE_ADDR) & ~7UL ;
LPC_LCD->LPBASE = (VIDEOWAITBUFFER_BASE_ADDR) & ~7UL ;

DMI_SDRAM->TransferType = GPDMA_TRANSFERTYPE_M2M;
DMI_SDRAM->TransferSize = 4000;
DMI_SDRAM->TransferWidth = 2;

for(j=0;j<6;j++){
for(i=0;i<8;i++){
DMI_SDRAM->ChannelNum = i;
DMI_SDRAM->SrcMemAddr = VIDEOWAITBUFFER_BASE_ADDR+4000*i*4+16000*8*j;
DMI_SDRAM->DstMemAddr = VIDEOBUFFER_BASE_ADDR+4000*i*4+16000*8*j;
GPDMA_Setup(DMI_SDRAM);
GPDMA_ChannelCmd(i,ENABLE);
}
for(i=0;i<200000;i++);
}

LPC_LCD->UPBASE = (VIDEOBUFFER_BASE_ADDR) & ~7UL ;
LPC_LCD->LPBASE = (VIDEOBUFFER_BASE_ADDR) & ~7UL ;
.
.
.
.

It work correctly , but is too slowly... How can i speedup copying???
my second problem is CLK of LCD. The LCD image have a some vibration! It is caused of low CLK frequency . but when i increase CLK frequency , LCD work but with noise... I think EMC or LCD not work at Maximum speed. please check my code :


voidInitSDMEM(){
uint32_t i=0;
volatile unsigned long Dummy;
PINSEL_ConfigPin(2,16,1); // /CAS
PINSEL_ConfigPin(2,17,1); // /RAS
PINSEL_ConfigPin(2,18,1); // CLK
PINSEL_ConfigPin(2,24,1); // CKE
PINSEL_ConfigPin(2,28,1); // LDQM
PINSEL_ConfigPin(2,29,1); // UDQM
PINSEL_ConfigPin(2,20,1); // /DYCS
for(;i<16;i++){
PINSEL_ConfigPin(3,i,1); // DATA(i)
}
for(i=0;i<15;i++){
PINSEL_ConfigPin(4,i,1); // DATA(i)
}
PINSEL_ConfigPin(4,25,1); // /WE
LPC_SC->PCONP |= (1<<11); // Power on EMC Clock
LPC_SC->EMCDLYCTL |= (4 <<16); // CLK = 100MHz According datasheet
LPC_EMC->DynamicControl = 0x0183;  // NOP COMMAND
for(i= 200*30; i;i--);
LPC_EMC->DynamicControl = 0x0103; // PALL COMMAND
LPC_EMC->Control = 1;
LPC_EMC->DynamicReadConfig = 1;
LPC_EMC->DynamicRP = P2C(SDRAM_TRP);
LPC_EMC->DynamicRAS = P2C(SDRAM_TRAS);
LPC_EMC->DynamicSREX = P2C(SDRAM_TXSR);
LPC_EMC->DynamicAPR = SDRAM_TAPR;
LPC_EMC->DynamicDAL = SDRAM_TDAL+P2C(SDRAM_TRP);
LPC_EMC->DynamicWR = SDRAM_TWR;
LPC_EMC->DynamicRC = P2C(SDRAM_TRC);
LPC_EMC->DynamicRFC = P2C(SDRAM_TRFC);
LPC_EMC->DynamicXSR = P2C(SDRAM_TXSR);
LPC_EMC->DynamicRRD = P2C(SDRAM_TRRD);
LPC_EMC->DynamicMRD = SDRAM_TMRD;
LPC_EMC->DynamicConfig0 = 0x0080680;
LPC_EMC->DynamicRefresh = 0x100;//P2C(SDRAM_REFRESH) >> 4;
LPC_EMC->DynamicRasCas0 = 0x303;
LPC_EMC->DynamicControl    = 0x00000083; // MODE COMMAND
Dummy = *((volatile uint32_t *)(SDRAM_BASE_ADDR | (0x33<<12)));
LPC_EMC->DynamicControl = 0x0000;
for(i = 100000; i;i--);
}



#define REFRESH_FREQ 100//Hz
#define LCDDCLK(uint8_t)(120000000*((1.0/REFRESH_FREQ)/(TFTLCD_X_SIZE*TFTLCD_Y_SIZE)))

void TFTLCDInit(){
uint32_t i;
TFTLCDConfigPins();
LPC_LCD->CRSR_CTRL &=~(1<<0);
LPC_SC->PCONP |= 1;//Power On LCD Controller
LPC_LCD->TIMH = (HSW - 1)<<8 | (HFP - 1)<<16 | (HBP - 1)<<24;
LPC_LCD->TIMV = (LPP - 1)<<0 | (VSW - 1)<<10 | (VFP)<<16 | (VBP)<<24;
LPC_LCD->POL = LCDDCLK | ( (ACB - 1)<<6 ) | (IVS<<11) | (IHS<<12) | (IPC<<13) | (CPL-1)<<16;  // ~40Hz Refresh
LPC_LCD->CTRL = (6 << 1) | (1 << 5);
LPC_LCD->UPBASE = VIDEOBUFFER_BASE_ADDR & ~7UL ;
LPC_LCD->LPBASE = VIDEOBUFFER_BASE_ADDR & ~7UL ;
for (i = 0; i < ( sizeof(LPC_LCD->PAL) / sizeof(LPC_LCD->PAL[0]) ); i++)
  LPC_LCD->PAL = 0;  //Clear the color palette with black
LPC_LCD->CTRL |= (1<<0);/* LCD enable control bit */
for(i = TFTLCD_PWR_ENA_DIS_DLY; i; i--);
LPC_LCD->CTRL |= (1<<11);/* enable power */
}

Please help me...

Outcomes