LPC1778 emc init with sram k6x1008td2

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1778 emc init with sram k6x1008td2

632 Views
lpcware
NXP Employee
NXP Employee
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
Labels (1)
0 Kudos
5 Replies

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by AkshayHV on Thu Jan 22 05:56:10 MST 2015
Hello,

I am also using a same connection you did for SRAM with LPC1788 but the WE pin i am using a GPIO which i am operating manually. but the when i write some data into my SRAM if i read from any position of SRAM the data which i am getting is the last byte i wrote into the SRAM.
Kindly revert back if you know the solution for this.


regards
Akshay H V
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Dfcbkbq on Mon Sep 15 21:28:37 MST 2014
Thank you so much! It is really helped!
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Mon Sep 15 09:33:50 MST 2014
I think that you need to set bit 7 (PB) in the static config x register.
I.e
LPC_EMC->StaticConfig0 = 0x80;


Also do not set LPCEMC->Control to 1 until AFTER all the other settings.

For an expanation with wave form pictures, see the data sheet (not the user manual).

HTH, Mike

0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Dfcbkbq on Sun Sep 14 21:39:37 MST 2014
But there is no any SRAM example. Just only SDRAM, norflash and nandflash.
0 Kudos

511 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xianghuiwang on Fri Sep 12 17:45:04 MST 2014
Hi,

you can reference the emc sample code from below link:

http://www.lpcware.com/content/nxpfile/lpc177x-and-lpc178x-cmsis-compliant-standard-peripheral-firmw...

regards,
0 Kudos