AnsweredAssumed Answered

LPC1785 EMC with SDRAM freezes

Question asked by lltsu on Aug 9, 2016
Latest reply on Aug 14, 2016 by Hui_Ma

Hello,

I'm trying to use LPC1785 with AS4C4M16SA SDRAM. The controller is running at 120 MHz and the EMC controller at 60 MHz.

It looks like that the first 8 bytes of the memory (from 0xA0000000 to 0xA0000007) work the way they should, but reading from any other location freezes the controller. I can write to any location I want to, but it looks like that writing to a memory location bigger than 0xA0000080 corrupts the first 8 bytes of data.

 

What could be the problem?

 

The SDRAM and LPC1785 are connected like this:

DQ0-DQ15     -     EMC_D0-EMC_D15

A0-A11           -      EMC_A0-EMC_A11

BA0                -      EMC_A13

BA1                -      EMC_A14

LDQM            -      EMC_DQM0

UDQM           -      EMC_DQM1

WE                 -      EMC_WE

CAS               -      EMC_CAS

RAS               -      EMC_RAS

CS                 -      EMC_DYCS0

CLK               -      EMC_CLK0

CKE              -      EMC_CKE0

 

Code to initialize the SDRAM:

 

 

     // clock divide

    LPC_SC->EMCCLKSEL = 1;

 

    // ensure that the power to the EMC module is on

    LPC_SC->PCONP |= (1 << 11);

 

    // reset EMC on any controller reset

    // enable burst control

    LPC_SC->SCS &= ~(0b111);

 

    // enable EMC in normal power mode and set normal memory map

    LPC_EMC->Control = 0b001;

 

    // little endian mode

    LPC_EMC->Config = 0;

 

    // enable dynamic memory, CLKOUT runs continously

    LPC_EMC->DynamicControl = 0b00000110;

 

    // disable buffer for initialization and write configuration values

    LPC_EMC->DynamicConfig0 = (0b000101 << 7);

 

    // set RAS and CAS

    LPC_EMC->DynamicRasCas0 = 3 + (3 << 8);

 

    // set the SDRAM refresh rate to small value for PALL command

    LPC_EMC->DynamicRefresh = 2;

 

    // issue PALL command

    LPC_EMC->DynamicControl = 0x103;

    volatile int i;

    for (i = 0; i < 128 * 2; i++) {

          __NOP();

    }

 

    // set the SDRAM refresh rate

    LPC_EMC->DynamicRefresh = 54;

 

    // issue MODE command to the SDRAM

    LPC_EMC->DynamicControl = 0x83;

 

    // configure SDRAM

    volatile unsigned int temp = *((volatile unsigned int *) (0xA0000000 + (0x33 << (2 + 8 + 1))));

 

    // issue normal command

    LPC_EMC->DynamicControl &= ~(0b11 << 7);

 

    // enable buffer

    LPC_EMC->DynamicConfig0 |= (1 << 19);

Outcomes