к LPC2468 подключил MT48LC2M32
физически подключил так:
D0...D31 - D0...D31
A0...A10 - A0...A10
A11, A12 - BA0, BA1
остальные сигналы один в один
инициализация:
взято из code.bundle.lpc23xx.lpc24xx.uvision.zip и переделано под IAR 5.11
void SDRAMInit( void )
{
DWORD i, dummy = dummy;
/*************************************************************************
* Initialize EMC and SDRAM
*************************************************************************/
// SCS |= 0x00000002; /* Reset EMC */
EMCCONTROL = 0x00000001; /*Disable Address mirror*/
PCONP |= 0x00000800; /* Turn On EMC PCLK */
PINSEL5 = 0x55010115;
PINSEL6 = 0x55555555;
PINSEL7 = 0x55555555;
PINSEL8 = 0x55555555;
PINSEL9 = 0x00040000;
EMCDYNAMICRP = 1; /* command period: 3(n+1) clock cycles */
EMCDYNAMICRAS = 3; /* RAS command period: 4(n+1) clock cycles */
EMCDYNAMICSREX = 5; /* Self-refresh period: 8(n+1) clock cycles */
EMCDYNAMICAPR = 1; /* Data out to active: 3(n+1) clock cycles */
EMCDYNAMICDAL = 5; /* Data in to active: 5(n+1) clock cycles */
EMCDYNAMICWR = 1; /* Write recovery: 2(n+1) clock cycles */
EMCDYNAMICRC = 5; /* Active to Active cmd: 6(n+1) clock cycles */
EMCDYNAMICRFC = 5; /* Auto-refresh: 6(n+1) clock cycles */
EMCDYNAMICXSR = 5; /* Exit self-refresh: 8(n+1) clock cycles */
EMCDYNAMICRRD = 1; /* Active bank A->B: 2(n+1) clock cycles */
EMCDYNAMICMRD = 1; /* Load Mode to Active cmd: 3(n+1) clock cycles */
EMCDINAMICRDCFG = 1; /* Command delayed strategy */
/* Default setting, RAS latency 3 CCLKs, CAS latenty 3 CCLKs. */
EMCDYNAMICRASCAS0 = 0x00000303;
/* 64MB, 2Mx32, 4 banks, row=11, column=8 */
EMCDYNAMICCFG0 = 0x00004300;
delayMs(100);
/*
// 256MB, 16Mx16, 4 banks, row=13, column=9
EMCDYNAMICCFG0 = 0x00000680;
delayMs(100);
*/
/* Mem clock enable, CLKOUT runs, send command: NOP */
EMCDINAMICCTRL = 0x00000183;
delayMs(200);
/* Send command: PRECHARGE-ALL, shortest possible refresh period */
EMCDINAMICCTRL = 0x00000103;
/* set 32 CCLKs between SDRAM refresh cycles */
EMCDINAMICRFR = 0x00000002;
for(i = 0; i < 0x40; i++) asm (" nop"); /* wait 128 AHB clock cycles */
/* set 28 x 16CCLKs= 448 CCLK = 13 us between SDRAM refresh cycles */
EMCDINAMICRFR = 28;
/* To set mode register in SDRAM, enter mode by issue
MODE command, after finishing, bailout and back to NORMAL mode. */
/* Mem clock enable, CLKOUT runs, send command: MODE */
EMCDINAMICCTRL = 0x00000083;
/* Set mode register in SDRAM */
/* Mode regitster table for Micron's MT48LCxx */
/* bit 9: Programmed burst length(0)
bit 8~7: Normal mode(0)
bit 6~4: CAS latency 3
bit 3: Sequential(0)
bit 2~0: Burst length is 8
row position is 12 */
dummy = *((volatile unsigned int*)(SDRAM_BASE_ADDR | (0x33 << 11)));
EMCDINAMICCTRL = 0x00000000; /* Send command: NORMAL */
EMCDYNAMICCFG0 |= 0x00080000; /* Enable buffer */
delayMs(1);
return;
}
больше всего смущает dummy = *((volatile unsigned int*)(SDRAM_BASE_ADDR | (0x33 << 11)));
на сколько сдвигать надо?
однако при записи в SDRAM и последующей проверке оказывается, что записаны немного странные значения:
адрес 0xA0000000:
00000101 00000101 00000101 00000101
00000105 00000105 00000105 00000105
00000109 00000109 00000109 00000109
0000010d 0000010d 0000010d 0000010d
....
а с адреса 0xA0001000 идёт
ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff
ffffffff ffffffff ffffffff ffffffff
....
с адреса 0xA0002000 опять начинается что-то типа
00000101 00000101 00000101 00000101
00000105 00000105 00000105 00000105
00000109 00000109 00000109 00000109
0000010d 0000010d 0000010d 0000010d
....
и так далее повторяется через каждую 0x1000
может кто уже подключал такую память?
какие будут идеи?