lpcware

LPC1778 emc init with sram k6x1008td2

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Dfcbkbq on Fri Sep 12 05:53:33 MST 2014
The shematic is follows:
[img=1024x692]https://dl.dropboxusercontent.com/u/5149769/sramConnection.png[/img]

I try to init emc controller for it. Here my code:


void SRAMInit( void )
{
volatile uint32_t i;
volatile unsigned long Dummy;

LPC_IOCON->P3_0 = 0x21;
LPC_IOCON->P3_1 = 0x21;
LPC_IOCON->P3_2 = 0x21;
LPC_IOCON->P3_3 = 0x21;
LPC_IOCON->P3_4 = 0x21;
LPC_IOCON->P3_5 = 0x21;
LPC_IOCON->P3_6 = 0x21;
LPC_IOCON->P3_7 = 0x21;

LPC_IOCON->P4_0 = 0x21;
LPC_IOCON->P4_1 = 0x21;
LPC_IOCON->P4_2 = 0x21;
LPC_IOCON->P4_3 = 0x21;
LPC_IOCON->P4_4 = 0x21;
LPC_IOCON->P4_5 = 0x21;
LPC_IOCON->P4_6 = 0x21;
LPC_IOCON->P4_7 = 0x21;
LPC_IOCON->P4_8 = 0x21;
LPC_IOCON->P4_9 = 0x21;
LPC_IOCON->P4_10 = 0x21;
LPC_IOCON->P4_11 = 0x21;
LPC_IOCON->P4_12 = 0x21;
LPC_IOCON->P4_13 = 0x21;
LPC_IOCON->P4_14 = 0x21;
LPC_IOCON->P4_15 = 0x21;
LPC_IOCON->P5_0 = 0x21;

LPC_IOCON->P4_24 = 0x21;
LPC_IOCON->P4_25 = 0x21;

LPC_IOCON->P4_31 = 0x00;
LPC_GPIO4->DIR |= (1<<31);
LPC_GPIO4->SET |= (1<<31);
LPC_IOCON->P4_30 = 0x21;
//EMC_Init();
// Init SDRAM controller
LPC_SC->PCONP   |= 0x00000800;
LPC_SC->EMCDLYCTL |= (8<<0);
LPC_SC->EMCDLYCTL |=(8<<8);

LPC_SC->EMCDLYCTL |= (8<<16);

LPC_EMC->Control = 0x01;
LPC_EMC->Config = 0x00;
LPC_EMC->StaticExtendedWait = 0x00;
LPC_EMC->StaticConfig0 = 0x00;
LPC_EMC->StaticWaitWen0 = 0x01;
LPC_EMC->StaticWaitOen0 = 0x01;
LPC_EMC->StaticWaitRd0 = 0x01;
LPC_EMC->StaticWaitWr0 = 0x01;

}


Scatter file:


LR_IROM1 0x00000000 0x00080000  {    ; load region size_region
  ER_IROM1 0x00000000 0x00080000  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
  }
  RW_IRAM1 0x10000000 0x00010000  {  ; RW data
   .ANY (+RW +ZI)
  }
 
  RW_IRAM2 0x20000000 0x00007FFF  {  ; RW data
.ANY (+RW +ZI)
  }
 
  RW_RAM1 0x80000000 UNINIT 0x02000000  {  ; RW data
   ;rsramTesr.o (.data)
   sramTesr.o (.bss)
  
  }
}


In sramTesr.cpp:

unsigned char sramData[50];


And main.cpp

u8 hello[] = "Hello!\r";
extern unsigned char sramData[50];

int main (void)
{
SystemInit();

/** uart for logs */
UartConfigType uartConfig;
uartConfig.baud = UART_BAUD_115200_PCKL_60MHZ;
uartConfig.parity = None;
uartConfig.numOfDataBits = 8;
uartConfig.numOfStopBits = 1;
uartConfig.useInterrupt = 1;
uartConfig.interruptHadler = userInterruptHandler;
uart.init (&uartConfig);

/**< init sram */
SRAMInit ();
/** waiting after init */
ngPlcTimerInit (200);
ngPlcTimerStart();
while (ngPlcTimerExpired() == 0);

/** placing data to sram */
for (u8 i = 0; i < 8; i++)
{
sramData = hello;
}

/** reading data from sram */
for (u8 i=0; i<8; i++)
{
while (uart.readyToSend() == 0);
uart.sendChar (sramData); /** data in logs are wrong! */
}

while(1)
{
}
}


So I put data in sram, then read it and sent to UART. It's not working, data was not been written to sram. Pin WE not go low. What is wrong?

Regards

Outcomes