lpc43xx interface with SDRAM

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

lpc43xx interface with SDRAM

706 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gvandenbosch on Wed Apr 15 02:34:18 MST 2015
Hello.

I have interfaced SDRAM (AS6C8016) with the LPC43xx.
*chip datasheet: http://www.alliancememory.com/pdf/AS6C8016.pdf

To initalize this with the EMC I have used the following code:

#define SDRAM_BASE_ADDR 0x28000000

EMCFlashInit();
vEMC_InitSRDRAM(SDRAM_BASE_ADDR, EMC_SDRAM_WIDTH_16_BITS, EMC_SDRAM_SIZE_16_MBITS, EMC_SDRAM_DATA_BUS_16_BITS, SDRAM_COL_ADDR_BITS);


It executes this function without any problems.

But when I try to use the SDRAM I am getting into trouble, I can not make my buffers larger than 128 bytes.

I am executing the following test where I copy some random data into sdram:
memcpy(vSDRAM,uacTest,128);

unsigned char acRead[200];
memcpy(acRead,vSDRAM,128);


This works fine until 128 bytes, but  with more than 128 bytes it crashes.

However if I add a second buffer of 128 bytes and perform same sort of test like the following it works fine:
memcpy(vSDRAM+128,uacTest,128);
unsigned char acRead2[260];
memcpy(acRead2,vSDRAM+128,128);


I am not very familiar with sdram, is this default behaviour? Or is there going something wrong in my configuration?
My thought were that I could make the buffer as large as I want as long it doesn't exceeds the size of my sdram chip.

Cheers,
Gerard
Labels (1)
0 Kudos
4 Replies

563 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bavarian on Tue Apr 28 08:14:45 MST 2015
Hello Gerard,

a 16-bit device normally starts with a connection of MCU_ADDR_1 to its A0 pin.
With a 16-bit device you don't use MCU_ADDR_0 at all, the byte addressing is done with LB and UB.

However, at least 50% of the memory on your board should be addressable. Just disable the A0 address line (configure it to GPIO) and then give it a try.
I leave it up to you to find out which addresses in the SRAM you can reach with your wiring   8-)


This init code should do the job, take care that the value for the EMC clock in the macro DELAYCYCLES is known (and correct).
See registers CREG6 and CLK_M4_EMC_CFG.
/* AS6C8016 SRAM
 Read Cycle Time 55 nS minimum
 Chip Enable Access Time 55 ns maximum
 Address Access Time 55 ns max
 Toe 30 ns max
 CE/OE high to inactive output 16 ns*/

/* Set up EMC Controller for CS0 */
LPC_EMC->CONTROL = 0x01;
LPC_EMC->STATICCONFIG0 = (1<<7) | 1;

LPC_EMC->STATICWAITRD0 = DELAYCYCLES(55)+1;
LPC_EMC->STATICWAITPAG0 = DELAYCYCLES(55)+1;
LPC_EMC->STATICWAITOEN0 = DELAYCYCLES(30)+1;

LPC_EMC->STATICCONFIG0 |= 1 << 19;



Regards,
NXP Support Team
0 Kudos

563 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gvandenbosch on Mon Apr 20 10:37:49 MST 2015
Hello,

It indeed is SRAM, stupid mistake by me, I left out the initialization of the sdram now.
This works better but now having the same problem after 976 bytes.

For the initialization I did the following:

/* AS6C8016 SRAM
 Read Cycle Time 55 nS minimum
 Chip Enable Access Time 55 ns maximum
 Address Access Time 55 ns max
 Toe 30 ns max
 CE/OE high to inactive output 16 ns*/

/* Set up EMC Controller */
LPC_EMC->STATICWAITRD0 = DELAYCYCLES(55)+1;

LPC_EMC->STATICWAITPAG0 = DELAYCYCLES(55)+1;
LPC_EMC->CONTROL = 0x01;

LPC_EMC->STATICCONFIG0 = (1<<7) | 1;
LPC_EMC->STATICWAITOEN0 = DELAYCYCLES(30)+1;


/*Enable Buffer for External Flash*/
LPC_EMC->STATICCONFIG0 |= 1<<19;


The timings I filtered out of the datasheet.

The pinconfig I have added as attachment, because it triggered the spam filter on this forum.

I have attached screenshots of my schematic.
I would like to know what the best way is to debug this? Is there something wrong with the code or should I look for the problem into the hardware?

Thanks for the help so far.

Cheers,
Gerard
0 Kudos

563 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mc on Thu Apr 16 06:52:14 MST 2015
Hello Gerard,
Please also post your schematic.
0 Kudos

563 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bavarian on Thu Apr 16 04:31:30 MST 2015
Hello Gerard,

>> It executes this function without any problems.
Well, you could write anything into this function call, it will always return. The function doesn't know which SDRAM is connected. You will notice it only afterwards, when the SDRAM doesn't work (correctly).

>> Or is there going something wrong in my configuration?
I would simply try to connect the AS6C8016 to the port where it belongs to --> the static memory interface port ;-)
This device is an SRAM and not an SDRAM.

Regards,
NXP Support Team
0 Kudos